Context menu for different tree view items

1 Answer 420 Views
Menu TreeView
Brian
Top achievements
Rank 1
Iron
Brian asked on 07 Dec 2021, 06:48 AM | edited on 07 Dec 2021, 07:06 AM

Hi,

I am currently integrating the Tree View & context menu in Kendo UI Jquery. I would need to show different set of context menus for different category. Is there a way to do it? For 1st & 2nd level will be different context menu. 3rd level will not have any context menu.

 

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 09 Dec 2021, 10:29 AM

Hi Brian,

You could add a field that holds information regarding the node level. Then you could use a TreeView template to wrap the element in add a span with class according to the node level. Below is an example:

 template: "<span class='#: item.levelClass #'>#: item.text #</span>",

Next, you could use the ContextMenu filter option to display the needed context menu only on the nodes with a certain class.

$("#context-menu").kendoContextMenu({
          target: "#treeview",
          filter: '.first'
 });

The approach is demonstrated in the Dojo linked here.

I hope this helps.

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Menu TreeView
Asked by
Brian
Top achievements
Rank 1
Iron
Answers by
Neli
Telerik team
Share this question
or