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?
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 #\ #} #"),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.