[英]How to filter already filtered datasource in Kendo grid
In my application, I'm using kendo grid and I'm using kendoDropDownList
to filter data source as follows,在我的应用程序中,我使用剑道网格,我使用kendoDropDownList
过滤数据源,如下所示,
<div class="pull-right">
<label>Select Value</label>
<select class="form-control" id="selectGroup">
<option selected="selected">Group A</option>
<option>Group B</option>
<option>All</option>
</select>
</div>
How I calling the JS我如何调用 JS
$('#selectGroup').kendoDropDownList({
autoBind: false,
change: function (e) {
var grid = $('#allUsersGrid').data('kendoGrid');
var field = 'Group';
var operator = 'eq';
var value = e.sender.value();
if (value == "Group A" || value == "Group A") {
value = e.sender.value() == "Group A" ? true : false;
grid.dataSource.filter({
field: field,
operator: operator,
value: value
});
} else {
grid.dataSource.filter([]);
}
}
});
The above code works fine and now I need to search value from above filtered
result.上面的代码工作正常,现在我需要从上面的filtered
结果中搜索值。 How can I do it?我该怎么做?
I wrote the search function as follows我写的搜索功能如下
function SearchProductServices() {
var grid = $("#allUsersGrid").data("kendoGrid");
var field = 'MemberName';
var operator = 'contains';
var value = $("#txtSearchSearch").val();
grid.dataSource.filter({
field: field,
operator: operator,
value: value
});
}
But the above function searching value from the whole grid.但是上面的函数从整个网格中搜索值。 But I need to search value from the filtered grid.但我需要从过滤后的网格中搜索值。 How can I do it我该怎么做
You can send an array of objects to keep the current filter and add a new one in your second function.您可以发送一组对象以保留当前过滤器并在第二个函数中添加一个新过滤器。
grid.dataSource.filter({
"filters": [
{
"field": field,
"operator": operator,
"value": value
},
{
"field": field2,
"operator": operator2,
"value": value2
}
],
"logic": "and"
})
Some documentation: https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/filter一些文档: https : //docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/filter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.