Hi!
I need to be able to select the top menu item when any child item is selected. Here is my javascript for finding the top menu item of the clicked child item.
var menuItem = eventArgs.getItem();
var tmpMenuItem = menuItem;
while (tmpMenuItem.get_parentItem() != null)
{
tmpMenuItem = tmpMenuItem.get_parentItem();
}
//Here I want to select the tmpMenuItem which will be the top menuItem of the clicked child item.
I only find the get_selected() function but I need a set function here.
Is this possible in any way?
Hello,
Would explain in more details, what o you need to achieve. WebDataMenu support only single selection. That means that only one item can be "Selected" at a time. Maybe you will just need to apply some style on the top-most item.
The menu item itsef has a method "get_stateCssClass(state)", where state can be:
Once you have the CssClass you need, you can use the ASP.NET AJAX function:Sys.UI.DomElement.addCssClass(element, className);(http://msdn.microsoft.com/en-us/library/bb310966.aspx)to add desired cssClass.
However you should not forget to remove when you don't need it anymore, by using similar function:Sys.UI.DomElement.removeCssClass(element, className);http://msdn.microsoft.com/en-us/library/bb310826.aspx
You can get the DOM Element via the "get_element()" property of DataMenuItem:https://ko.infragistics.com/help/aspnet/web-webdatamenu
Thanx for your reply!
I tried your suggestion but I'm not able to get it to work. Here is what I did:
var cssSelected = tmpMenuItem.get_stateCssClass("Selected");
Sys.UI.DomElement.addCssClass(tmpMenuItem, cssSelected);
The CSS class I get is the igdm_MenuItemHorizontalRootSelected. The reason I think this is not working is that the menuitem already has this css class attached to it, but it is not used since the menuitem is not selected.
Am I doing something wrong here or is this simply not working as suggested?
Any suggestions regarding this matter?