How to add class to row (<TR>) on TreeList from Datasource value ?
Thank You
1 Answer, 1 is accepted
0
Nikolay
Telerik team
answered on 16 Nov 2020, 01:06 PM
Hello Jérôme,
I suggest in the dataBound event, obtain all rendered items (rows) via the items() method, loop through them and use the dataItem() method to get the corresponding data item, then add a custom class(es) to the TR, based on some property of the data item:
Events(e => e.DataBound("onDataBound")
...
function onDataBound(e) {
var items = e.sender.items();
var data = e.sender.dataSource.data()
items.each(function(idx, item){
$(item).addClass(data[idx].class); //class is the property to be used as a class name
});
}
This can be examined live in the following Dojo demo:
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/.