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

Custom class to row based on dataItem

1 Answer 434 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saop
Top achievements
Rank 1
Saop asked on 12 Oct 2016, 10:21 AM

How can I add custom class to row based on dataItem?

I think I could use rowTemplate, but that would ignore columns.template which is not OK. I also don't want to change rowTemplate just add some custom classes.

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Topalov
Telerik team
answered on 12 Oct 2016, 01:28 PM
Hello MatjaĆŸ,

You can handle 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 conditionally add custom class(es) to the TR, based on some property of the data item:

http://dojo.telerik.com/iLaNUV

The following how-to article from our documentation shows alternative approaches as well:

http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Layout/style-rows-cells-based-on-data-item-values

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Tags
Grid
Asked by
Saop
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or