在KendoUI网格中搜索所有列 [英] Search All Columns in KendoUI Grid
问题描述
我正在尝试为kendoUI网格创建搜索框.我已经可以开始基于一个字段进行搜索了,但是我希望搜索框中的值可以搜索网格中的所有列.
I am trying to create a search box for a kendoUI grid. I have been able to get a start on doing a search based on one field however I would like the value in my search box to search all columns in the grid.
function() {
grid.data("kendoGrid").dataSource.filter({
field: "ProductName",
operator: "contains",
value: $('#category').val()
});
}
我尝试在此处使用or逻辑运算符: jsfiddle.net 但是我不能似乎可以正常使用....(请参阅或逻辑按钮)
I tried using the or logic operator here: jsfiddle.net however I can't seem to get it to work.... (see or logic button)
推荐答案
我认为,如果要匹配,应该对fee
说eq
或对fi
说 eq
这是两个条件之一.
I think that you should say eq
to fee
or eq
to fi
if you want to match one of the two conditions.
我已经稍微修改了您的小提琴来显示它.如果在搜索框中键入内容,则将过滤与ProductName
列或QuantityPerUnit
列匹配的记录.
I´ve slightly modified your fiddle to show it. If you type on the search box you will filter records matching either ProductName
column or QuantityPerUnit
.
//change event
$("#category").keyup(function () {
var val = $('#category').val();
$("#grid").data("kendoGrid").dataSource.filter({
logic : "or",
filters: [
{
field : "ProductName",
operator: "contains",
value : val
},
{
field : "QuantityPerUnit",
operator: "contains",
value : val
}
]
});
});
重要:为了使它能够正常工作,我不得不将jQuery版本更新为1.8.2,以防万一我也将KendoUI更新到了最新版本.
IMPORTANT: I have had to update jQuery version to 1.8.2 for making it work and just in case I have updated KendoUI, as well, to the latest version.
这篇关于在KendoUI网格中搜索所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!