动态列上的剑道网格过滤器 [英] Kendo Grid Filter on a dynamic column
问题描述
我正在开发一个Kendo Grid,它有一个Status列,它是几个其他列的状态汇总。我将各个状态跟踪为整数值,聚合列应显示最少的状态。现在,使用模板,我能够很好地呈现Status列的文本,但问题是我希望此列可以过滤。在计算该值时,这不起作用。
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.
在DataSource中,这是我声明自定义字段的方式,
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?
推荐答案
而不是将 Status
定义为中的函数model
,将其作为计算字段添加到 model.parse
中。例如:
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;
}
}
然后在模板中删除()
:
template: kendo.template("#if (HasError) {# <strong class='clrRed' > \#= Status #\ </strong> #} else { # \#= Status #\ #} #"),
这篇关于动态列上的剑道网格过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!