This is a migrated thread and some comments may be shown as answers.

Radmenu FindItem

4 Answers 417 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Marcio Nascimento
Top achievements
Rank 1
Marcio Nascimento asked on 11 Aug 2009, 03:22 PM
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

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Aug 2009, 04:48 AM
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.
0
Marcio Nascimento
Top achievements
Rank 1
answered on 12 Aug 2009, 12:34 PM
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
0
Marcio Nascimento
Top achievements
Rank 1
answered on 12 Aug 2009, 03:19 PM
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
0
KSBA Techie
Top achievements
Rank 1
answered on 04 Feb 2010, 07:31 PM
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.
Tags
Menu
Asked by
Marcio Nascimento
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Marcio Nascimento
Top achievements
Rank 1
KSBA Techie
Top achievements
Rank 1
Share this question
or