簡體   English   中英

動態列上的Kendo網格過濾器

[英]Kendo Grid Filter on a dynamic column

我正在Kendo網格上工作,該網格的“狀態”列是其他幾個列的狀態的總和。 我將各個狀態跟蹤為整數值,並且合計列應顯示最少的狀態。 現在,使用模板,我可以很好地呈現“狀態”列的文本,但是,問題是我希望該列是可過濾的。 由於該值已計算,因此無法正常工作。

在DataSource中,這就是我聲明自定義字段的方式,

schema: {
    model: {
        Status: function () {
            return helper.GetStatus(this.EntriesStatus);
        }
    }
}

這就是我在Column定義中使用它的方式,

{
    field: "Status",
    title: "Status",
    width: "100px",
    filterable: true,
    template: kendo.template("#if (HasError) {# <strong class='clrRed' > \#= Status() #\ </strong> #} else { # \#= Status() #\ #} #"),
    hidden: false,
    menu: false
}

誰能指出我要去哪里或者更有效的出路?

與其在model中將Status定義為函數,不如將其添加到model.parse作為計算字段。 例如:

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 #\ #} #"),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM