1

我的例子:http ://dojo.telerik.com/oWABE/2

这里我有一个包含“状态”的数据对象,它是一个整数!(它是 1,2 或 3)

在我的网格中,它掩盖了新的、待定的和关闭的

为了显示字符串(New、Pending 和 Closed),我在 shema -> 中创建了一个解析函数,用于过滤以处理解析值,不能在列定义中使用模板,但必须在数据源中解析它!

Status: { type: "int",
         parse: function(status) {    
         console.log(status,"stat");            
           switch(status){
             case 1: return"New"; break;
             case 2: return"Pending"; break;
             case 3: return"Solved"; break;
             case 5: return"Closed"; break;
          }
     }
},

调用此解析器时有一个“console.log”,我注意到之后!我过滤“新”日志显示:

n stat
undefined "stat"

...当我第一次运行日志读取的页面时(如预期的那样):

1 "stat"
2 "stat"
3 "stat"

过滤器不起作用(尝试过滤“新”作为示例)

有什么帮助吗?

4

2 回答 2

1

我不确定这是否正确,但试试这个例子:

.kendoDropDownList({
    dataSource: new kendo.data.DataSource({
        data: [
            { title: "Software Engineer" },
            { title: "Quality Assurance Engineer" },
            { title: "Team Lead" }
        ]
    }),
    dataTextField: "title",
    dataValueField: "title"
});

http://jsfiddle.net/jddevight/wGjCZ/

于 2015-09-03T13:31:27.543 回答
1

需要使用“schema.parse 选项”!

dataSource: {
              data: data,
              schema: {
                parse: function(response) {
                  var products = [];
                  for (var i = 0; i < response.length; i++) {
                    switch(response[i].Status){
                      case 1: response[i].Status = "New"; break;
                      case 2: response[i].Status = "Pending"; break;
                      case 3: response[i].Status = "Solved"; break;
                      case 5: response[i].Status = "Closed"; break;
                    }   
                    console.log(response[i]);
                    products.push(response[i]);
                  }                         
                  return products;
                },
                model: {
                  fields: {                         
                    OrderID: { type: "number" },           
                    Status: { type: "string"},
                    ShipCountry: { type: "string" }
                  }
                }
              }
            },

这是剑道的答案:http ://www.telerik.com/forums/kendo-filter-on-parsed-input-value

于 2015-09-04T14:37:22.790 回答