Kendogrid列过滤器

时间:2018-03-15 06:56:37

标签: javascript jquery kendo-ui kendo-grid

实施的最佳方法是什么: -

  1. 根据数据源中的idcolumn(key)过滤kendogrid中的列。
  2. id列在kendogrid中不可见,但必须根据值

    应用过滤器

1 个答案:

答案 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;
&#13;
&#13;