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

Different Context Menus for different Hierarchy Levels of a Treelist

2 Answers 86 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Serhat
Top achievements
Rank 1
Serhat asked on 26 Mar 2020, 09:22 AM

Hello,

 

I am using the kendo treelist to display a filesystem with folders and documents as the folder contents. The filesystem currently is rather flat, meaning that there is only the top-folder level and the document-level below it, i.e. no subfolders. I would like to implement a context menu for interacting with the treelist contents however the context menu needs to display different options when selecting a folder vs. when selecting a document which should trigger different events on the web page. Is it possible to use one context menu which displays these differing options in general for the two layers of my treelist. If I could display these different options then implementing the rest of the logic should be simple through the (select) handler.See the attached Stackblitz as a reference:

>>> https://stackblitz.com/edit/angular-rla8zp

Ideally the option 'Lock Folder' should only be displayed when selecting a folder and the option 'Edit Document' likewise only when a document is selected

2 Answers, 1 is accepted

Sort by
0
Accepted
Svet
Telerik team
answered on 30 Mar 2020, 06:11 AM

Hi Serhat,

Thank you for the provided example. What could be done is to utilize the (cellClick) event of the TreeList and to set a flag according to the clicked row dataItem.type. That will allow to differentiate between a folder and a file row, which will allow to change the items used by the ContextMenu accordingly. Please check the following example demonstrating such approach:

https://stackblitz.com/edit/angular-rla8zp-zspxop?file=app/app.component.ts

I hope this helps.

Regards,
Svetlin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Serhat
Top achievements
Rank 1
answered on 30 Mar 2020, 10:44 AM

Hi Svetlin,

Thank you very much for your reply, that was very helpful :)

Best regards,

Serhat

Tags
TreeList
Asked by
Serhat
Top achievements
Rank 1
Answers by
Svet
Telerik team
Serhat
Top achievements
Rank 1
Share this question
or