我的例子:http://dojo.telerik.com/oWABE/2
这里我有一个包含"status“的数据对象,它是一个整数!(是1、2或3)
在我的网格中,它屏蔽了新的、待定的和关闭的
为了显示字符串(新建、挂起和关闭),我在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“,而我注意到的是之后!我为"New“筛选日志,内容如下:
n stat
undefined "stat"...when I首先运行日志读取的页面(如预期的那样):
1 "stat"
2 "stat"
3 "stat"该过滤器不起作用(以“新建”为例尝试筛选)
有什么帮助吗?
发布于 2015-09-04 14:37:22
需要使用"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-03 13:31:27
我不确定这是否正确,但是试试下面的例子:
.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/
https://stackoverflow.com/questions/32244271
复制相似问题