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

RadMenu X Root Item X Child Item

1 Answer 45 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Ernandes
Top achievements
Rank 1
Ernandes asked on 17 Aug 2008, 01:33 AM
Hi there,

When creating a RadMenu have root item and 2 child items, by clicking on an item child how to get the name of the root item?

follows an example

function onClicking(sender, eventArgs)
    {

var menu = $find("<%= RadMenu1.ClientID %>");
var items = menu.get_items();

alert("item: " + items.getItem(0).get_text());
    }


thus, if I have more than 1 root item, I can not get their name, how to get the name of the root item when you have more than 1?

I want that when you click on an child item, I get the name of the root item that child item.


1 Answer, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 18 Aug 2008, 11:00 AM

Hi Ernandes,

Please, try the following code:

function onClicking(sender, eventArgs)  
    {  
         
        var clickedItem = eventArgs.get_item();  
 
        if(clickedItem.get_level()>0)  
        {  
           var parent = clickedItem.get_parent();  
           while(parent.get_level()>0)  
           {  
             parent=parent.get_parent();  
           }  
          alert("item: " + parent.get_text());  
        }  
 
 
 
    }  
 

Kind regards,

Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Ernandes
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Share this question
or