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

how to know which subitem belong to which main menu item when user is clicked on on a command bar DropDownButton

1 Answer 82 Views
CommandBar
This is a migrated thread and some comments may be shown as answers.
vinson
Top achievements
Rank 1
vinson asked on 10 Mar 2017, 11:09 AM

Hi,

I am using a drop down button on the command bar. The number of main menu items unknown in advance, it depends on the number of year of records are stored in the local database. On each main menu item, there are fixed amount of submenu items representing 12 months of a year as shown in the attached image.

My question is how can I know a user has pressed the submenu item from its corresponding parent? Let's say user pressed the submenu item 'January' from the the main menu item '2017', hence, I can show each record stored in the database related to January not January 2016 or January  2018 and vice versa.

I have these line of codes in my application which me to detech which month a user has click a subitem. I just can't figuer out how to detech the click is from which parten..

menuItem[j].Items[m].Click += WonderingRecordsForm_MouseDown;

RadMenuItem clickedMenuItem = (RadMenuItem) sender;
Console.WriteLine(clickedMenuItem.Text);

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 14 Mar 2017, 12:42 PM
Hello Vinson,

Thank you for writing.

Each RadMenuItem exposes a HierarchyParent property which you can access and check which the actual parent is. For example, you can handle the Click event of an item and check for its parent:
private void radMenuItem_Click(object sender, EventArgs e)
{
    RadMenuItem item = (RadMenuItem)sender;
    var parent = item.HierarchyParent;
    if (parent != null)
    {
        //...
    }
}
 
I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
CommandBar
Asked by
vinson
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or