实施的最佳方法是什么: -
id列在kendogrid中不可见,但必须根据值
应用过滤器答案 0 :(得分:0)
一种可能的解决方案是显示列但隐藏值。不确定这是否非常用户友好(用户将如何知道要过滤的值)。如果这对您来说是可行的,则可以为id
列定义一个空的模板。
基于dojo
。
var ds = new kendo.data.DataSource({
data: [
{ name: "Jane Doe", age: 30, id: 1 },
{ name: "John Doe", age: 33, id: 2 }
],
filter: [
// omit all items, which id is equal to 1"
{ field: "id", operator: "eq", value: 1 }
]
});
$("#grid").kendoGrid({
columns: [
{ field: "name", filterable: { multi: true } },
{ field: "id", template: "" },
{ field: "age", filterable: { multi: true } }
],
dataSource: ds,
filterable: true
});
var ds = new kendo.data.DataSource({
data: [
{ name: "Jane Doe", age: 30, id: 1 },
{ name: "John Doe", age: 33, id: 2}
],
filter: [
// omit all items, which id is lesser than 10"
{ field: "id", operator: "eq", value: 1 }
]
});
$("#grid").kendoGrid({
columns: [
{ field: "id", template: "", filterable: { multi: true }, width: 50 },
{ field: "name",filterable:{ multi: true} },
{ field: "age" ,filterable:{ multi: true} }
],
dataSource: ds,
filterable: true
});

<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.221/styles/kendo.common.min.css"/>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.221/styles/kendo.silver.min.css"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.1.221/js/kendo.all.min.js"></script>
<div id="grid"></div>
&#13;