在 KendoUI 网格中搜索所有列 [英] Search All Columns in KendoUI Grid

查看:20
本文介绍了在 KendoUI 网格中搜索所有列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 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()
            });

        }

参见js小提琴示例

我在这里尝试使用 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)

推荐答案

我觉得你应该说eqfee or eqfi 如果你想匹配两个条件之一.

I think that you should say eq to fee or eq to fi if you want to match one of the two conditions.

我稍微修改了您的 fiddle 以显示它.如果您在搜索框中键入,您将过滤与 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆