Kendo TreeList command visible

1 Answer 196 Views
TreeList
Jaanus
Top achievements
Rank 1
Jaanus asked on 13 Dec 2021, 08:21 AM | edited on 13 Dec 2021, 12:59 PM

In Kendo Grid it is possible to show/hide buttons in command column conditionally.

How can I achieve that in TreeList?


command: [
	{
		imageClass: "k-i-info",
		name: "details",
		text: "Details",

		visible: function (dataItem) { return dataItem.LastName.charAt(0) !== "D" }

	}
]

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 15 Dec 2021, 12:15 PM

Hi, Jaanus,

The TreeList widget doesn't have the command visibility functionality built-in, however you can achieve it by utilizing the dataBound event:

        dataBound: function() {
          let treelist = this;
          let data = treelist.dataSource.data();
          
          data.forEach(function(x, i) {
            if(x.LastName.charAt(0) !== "D") {
              let row = treelist.element.find("[data-uid='"+x.uid+"']");
              row.find("[data-command='details']").hide();
            }
          });
        }

Runnable Dojo:

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

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

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