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

Class on Row

1 Answer 143 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
Veteran
n/a asked on 12 Nov 2020, 12:02 AM

Hello

 

How to add class to row (<TR>) on TreeList from Datasource value ?

 

Thank You

1 Answer, 1 is accepted

Sort by
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:

Let me know if you have any questions.

Regards,
Nikolay
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
n/a
Top achievements
Rank 1
Veteran
Answers by
Nikolay
Telerik team
Share this question
or