TreeList - Conditionally show Command

1 Answer 284 Views
TreeList
Kevin
Top achievements
Rank 1
Kevin asked on 30 Mar 2022, 05:10 PM

I know in the Grid component, there is a visible property that can be set on the columns.command.  That works well for conditionally showing a command.

I'm not seeing that in the TreeList.  How can I conditionally show a command in a TreeList based on the row data?

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Denchev
Telerik team
answered on 04 Apr 2022, 09:17 AM

Hi, Kevin,

You can use the dataBound event of the TreeList to programmatically show/hide the commands:

                      	dataBound: function(e) {
                          const data = this.dataSource.view();
                          data.forEach((item) => {
                            if(item.LastName == "Wooten" || item.LastName == "Weber") {
                              const row = this.element.find("tr[data-uid="+item.uid+"]");
                              // Classes:
                              // .k-grid-add
                              // .k-grid-delete
                              // .k-grid-edit
                              row.find(".k-grid-add").css("display", "none");
                            }
                          });
                        }

Runnable Dojo:

https://dojo.telerik.com/@gdenchev/IqasUVaf 

Best Regards,
Georgi Denchev
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.

Kevin
Top achievements
Rank 1
commented on 04 Apr 2022, 01:31 PM

That worked perfectly, thank you Georgi.

In my case, I was using a custom command so I used the command.className and then used your example to find the action using the custom CSS class name.

Tags
TreeList
Asked by
Kevin
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or