Hi,
I am using WebDataMenu as context menu, on the right click of a node in WebDataTree.
I have an urgent requirement where I need to change the icon of the context menu items in the client side based on the node which is clicked.
Can anyone kindly let me know how to change the context menu Image using javascript?
Hi nancy1985,
Thank you for posting in the community.
Below is some sample code illutrating how the icon of a WebDataMenu item may be changed on the client using some jQuery. Please note that this approach should work regardless of whether the control is a context menu or not:
//get a menu item's element var itemElement = ig_controls.WebDataMenu1.getItems().getItem(0).get_element(); //set a new icon for that item $(itemElement).find('.igdm_MenuItemVerticalIcon').first().attr("src", "ig_res/Default/images/add_down.gif");
//get a menu item's element var itemElement = ig_controls.WebDataMenu1.getItems().getItem(0).get_element();
//set a new icon for that item $(itemElement).find('.igdm_MenuItemVerticalIcon').first().attr("src", "ig_res/Default/images/add_down.gif");
Please let me know if this helps.
Hi Petar Ivanov,
Thanks for the reply.
Can you please provide me a sample application illustrating the same.
Also, I have tried the approach in the following way, but was unable to achieve i. Can you please let me know where I am going wrong:
var menu = $find("<%= contextMenu.ClientID %>");
var items = menu.getItems();
var menuItem = items.getItem(0);
var itemElement = menuItem.get_element();
$(itemElement).find('.igdm_MenuItemVerticalIcon').first().attr("src","ig_res/Default/images/add_down.gif");
Have you included the jQuery scripts in your project ? As requested I am attaching a sample demonstrating this scenario.
Please let me know if you have any questions.
Please feel free to contact me if you have any questions.