Conditionally set class on rows

1 Answer 6188 Views
Grid
Dale
Top achievements
Rank 1
Dale asked on 04 Sep 2015, 05:52 PM

I'm using a Kendo grid, razor style, in an MVC application, binding to an ajax data source.

Products in the grid can be one of two types, and I want to apply different styles (background color, bold text, indent) to the different types of rows.  I've seen examples using the ClientRowTemplate property, but I don't want to set the entire template for all the cells, as many columns already have their own templates.  Isn't there a mechanism to just set a css class on a row based on data from the item it's bound to?

 Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 08 Sep 2015, 11:13 AM
Hi Dale,

Thank you for contacting Telerik Support.

For traversing and applying custom styles to each row, depending on a value within that row, you should handle the client-side dataBind event of the grid and get reference to the data items (for retrieving the value). Once you have a reference to the item you can add custom class name to the TR element. 

For your convenience, following is a simple dojo example with such conditional styling:
Additionally, you can take a look at the following help article for more details on the matter:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Dale
Top achievements
Rank 1
commented on 09 Sep 2015, 01:24 PM

Works well, thanks!
Tags
Grid
Asked by
Dale
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or