Reputation: 61
I am working on a Kendo Grid which has a Status column that is an aggregate of statuses of several other columns. I track the individual statuses as integer values and the aggregate column should show the least of the statuses. Now, using template, I am able to render the text for the Status column fine, however, the problem is that I want this column to be filterable. This is not working as the value is calculated.
In DataSource, this is how I have declared the custom field,
schema: {
model: {
Status: function () {
return helper.GetStatus(this.EntriesStatus);
}
}
}
This is how I used it in the Column definition,
{
field: "Status",
title: "Status",
width: "100px",
filterable: true,
template: kendo.template("#if (HasError) {# <strong class='clrRed' > \#= Status() #\ </strong> #} else { # \#= Status() #\ #} #"),
hidden: false,
menu: false
}
Could anyone point out where I am going wrong or a more efficient way out?
Upvotes: 0
Views: 2449
Reputation: 40887
Instead of defining Status
as a function in the model
, add it in model.parse
as a computed field. Ex:
schema: {
parse: function (d) {
$.each(d, function (idx, elem) {
elem.Status = helper.GetStatus(elem.EntriesStatus);
});
return d;
}
}
And then in the template remove ()
:
template: kendo.template("#if (HasError) {# <strong class='clrRed' > \#= Status #\ </strong> #} else { # \#= Status #\ #} #"),
Upvotes: 1