Reputation: 355
Greeting,
I have a working demo here, almost similar with my situation.
I successfully make the text color change to red when Discontinued column is false using dataBound function. But when I click on Edit then I click back on Cancel then text color is gone. So how can make sure if I click Cancel the text color still in red?
Upvotes: 0
Views: 118
Reputation: 1669
You have to subscribe to the Cancel
event as well. For example:
dataSource: dataSource,
cancel: highlight,
dataBound: highlight,
...
function highlight() {
setTimeout(function() {
var grid = $("#grid").data("kendoGrid");
var data = grid.dataSource.view();
$.each(data, function (i, row) {
var element = $('tr[data-uid="' + row.uid + '"] ');
if (row.Discontinued == false) {
$(element).addClass("red");
}
});
}, 10);
}
The only downside with this solution is that there is this tiny timeout. I guess the Cancel
event is fired before the form fields have been removed, although this is not explicetly mentioned in the documentation https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/cancel
Upvotes: 2