I have been injecting a class into the row at runtime to handle conditional styling scenarios, such as "if status = 'urgent' addClass('urgent')". A row with 'urgent' class might be styled bold and red. Conditional styling requires that one examine one or more cells of the row, so I've been getting the dataItem for each row and looking at the data.
$(grid.tbody).find("> tr:not(.k-grouping-row, .k-detail-row, .k-group-footer)").each(function (idx, elem) {
var dataItem = grid.dataItem(elem);
if (dataItem.status == 'urgent') {
$(this).addClass('urgent');
}
})
One problem is that the injected class does not survive a grouping operation. If the user drags a column-header to group by that column, the custom class injected into the row does not accompany the row to its new location. The conditional style is not reapplied when the rows are grouped.
So I am wondering, is it possible to use templates to do this, so that the template sticks to the row even during a grouping operation? The "urgent" class would be appended to those data rows of the tbody (i.e. not into the grouping row, or the group header and group footer rows) where the value in cell3 = "urgent". Let's say the schema field to which cell3 has been bound is called "status".
Very important: We don't want to overwrite any class that Kendo puts into the row; we want to append a class.
Here's some pseudo-code. Is something along these lines possible?
$(grid.tbody).find("> tr:not(.k-grouping-row, .k-detail-row, .k-group-footer)").each(function (idx, elem) {
var dataItem = grid.dataItem(elem);
if (dataItem.status == 'urgent') {
$(this).addClass('urgent');
}
})
One problem is that the injected class does not survive a grouping operation. If the user drags a column-header to group by that column, the custom class injected into the row does not accompany the row to its new location. The conditional style is not reapplied when the rows are grouped.
So I am wondering, is it possible to use templates to do this, so that the template sticks to the row even during a grouping operation? The "urgent" class would be appended to those data rows of the tbody (i.e. not into the grouping row, or the group header and group footer rows) where the value in cell3 = "urgent". Let's say the schema field to which cell3 has been bound is called "status".
Very important: We don't want to overwrite any class that Kendo puts into the row; we want to append a class.
Here's some pseudo-code. Is something along these lines possible?
<script id=
"urgentTemplate"
type=
"text/x-kendo-tmpl"
>
<tr ${ if dataItem[status] == urgent this.addClass(urgent)} </tr>
If templates cannot be made to work in this manner way, or if they don't travel with the row when
it is grouped, it would be helpful to have an event that fired after each group section was instantiated,
exposing the rows of the group, so one could iterate them, examine the dataItem of each,
and reapply a custom class to the row when applicable.
Sorry about this orange text. I'm not sure how to inject pseudo-code into my question without
messing up the styling.