Radmenu FindItem

5 posts, 0 answers
  1. Marcio Nascimento
    Marcio Nascimento avatar
    54 posts
    Member since:
    Jul 2009

    Posted 11 Aug 2009 Link to this post

    Hello,

    I've been trying to find documentation about the Radmenu1.FindItem property and how to use conditions.
    Could someone provide any examples or documentation links?
    The problem is that I need to disable all items from a root and show those itens disabled.

    Thanks for any help.

    Marcio Nascimento
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2009 Link to this post

    Hi Marcio,

    You can use FindItemByText, FindItemByValue or FindItemByUrl in order to search an item based on item's text, value or url. See the example shown below.

    C#:
     
    protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e) 
        RadMenuItem item1 = (RadMenuItem) RadMenu1.FindItemByUrl("http://www.google.com"); 
        RadMenuItem item2 = (RadMenuItem) RadMenu1.FindItemByValue("Value"); 
        RadMenuItem item3 = (RadMenuItem) RadMenu1.FindItemByText("RadMenuItem Text"); 

    -Shinu.
  3. Marcio Nascimento
    Marcio Nascimento avatar
    54 posts
    Member since:
    Jul 2009

    Posted 12 Aug 2009 Link to this post

    Yes, Shinu. Thanks for the reply. You're right and this is very useful. However i'm interested in a property called FindItem only. See below what says Intellisense:

    Telerik.Web.UI.RadMenuItem RadMenu.FindItem(Predicate<Telerik.Web.UI.RadMenuItem> match)  
    match: The Predicate <> that defines the conditions of element to search for

    And I couldn't find any example of it.

    Thanks.

    Marcio Nascimento
  4. Marcio Nascimento
    Marcio Nascimento avatar
    54 posts
    Member since:
    Jul 2009

    Posted 12 Aug 2009 Link to this post

    Hi Shinu,

    I've been able to solve my problem using the code below to disable items from menu that have the same values.
    I don't know if its the most correct way to do that but it seems to work. The only thing that I need to do now is to prevent user from assessing pages manually.

        private void DisableItemsFromValue(string valuetodisable)  
        {  
            var items = RadMenu1.GetAllItems();  
            int total_items = items.Count;  
            for (int i=0; i < total_items; i++)  
            {  
                if (items[i].Value == valuetodisable)  
                {  
                    items[i].Enabled = false;  
                    items[i].NavigateUrl = "";  
                }  
            }  
        } 

    Thanks.

    Marcio Nascimento
  5. KSBA Techie
    KSBA Techie avatar
    27 posts
    Member since:
    Aug 2012

    Posted 04 Feb 2010 Link to this post

    Added a new server side method FindItem which has one argument match of type Predicate Generic Delegate. This method can be used to find an Item by some custom criteria.
Back to Top