jqGrid搜索运算符未定义 [英] jqGrid Search Operator Undefined

查看:100
本文介绍了jqGrid搜索运算符未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jqGrid中使用了内置的搜索功能,并开始在服务器端为运行搜索的查询获取一些错误.我将其范围缩小到jqGrid传递给服务器的过滤器参数:

I'm using the built in search functionality with jqGrid and started to get some errors on the server side for the query that runs to perform the search. I've narrowed it down to the filter params that jqGrid is passing to the server:

{
   "groupOp":"AND",
   "rules":[
      {
         "field":"FOO",
         "op":"ge",
         "data":"181"
      },
      {
         "field":"FOO",
         "op":"undefined",
         "data":"196"
      }
   ]
}

如您所见,第二个对象中的搜索运算符为'undefined'-很奇怪,因为选择搜索运算符时没有空白/空选项.有没有人见过这个?这是一个已知的问题?我根本无法重现它,因此我想知道用户是否正在做某些特殊"操作来引起这种情况.我正在用jQuery 1.4.2运行jqGrid 3.8.2.

As you can see the search operator in the second object is 'undefined' -- which is odd since there isn't a blank/empty option when choosing the search operators. Has anyone seen this before? Is this a known issue? I can not reproduce it on my end at all so I'm wondering if there is something 'special' my user is doing to cause this. I'm running jqGrid 3.8.2 with jQuery 1.4.2.

更新:我能够在IE 7中重现该错误.似乎在搜索查询中添加第二个参数会导致该浏览器中的操作符未定义.

Update: I am able to reproduce the error in IE 7. It seems adding a 2nd parameter to a search query results in an undefined operator in that browser.

更新2:似乎应该根据发行说明在jqGrid 3.6中解决此问题:

Update 2: It seems this was supposed to be fixed in jqGrid 3.6 per the release notes:

不修复IE7和IE6中的searchFilter 当更多时返回未定义的值 不只搜索一个字段.

Fix searchFilter in IE7 and IE6 not to return undefined value when more than one field is searched.

这显然是一个错误.我要在这里结束问题.

It's clearly a bug. I'm going to close the question here.

推荐答案

jQuery错误.解决方法是,您应在页面上包含以下代码

The problem and the workaroung is described here. The main problem is the jQuery bug. As the workaround you should include the following code on your page

// we use workaround from http://www.trirand.com/blog/?page_id=393/bugs/in-multiple-search-second-and-subsequent-ops-are-sent-as-undefined-in-ie6/
// to fix the bug in the jQuery.clone (see http://bugs.jquery.com/ticket/6793 and
// dscussion on the http://api.jquery.com/clone/
$.event.special.click = {
    setup: function() {
        if ($(this).hasClass("ui-search")) {
            $(this).bind("click", jQuery.event.special.click.handler);
        }
        return false;
    },
    teardown: function() {
        $(this).unbind("click", jQuery.event.special.click.handler);
        return false;
    },
    handler: function(event) {
        //$(".ui-searchFilter td.ops select").attr("name", "op");
        $(".ui-searchFilter td.ops select").filter(function () {
            return $(this).css("display") != "none";
        }).attr("name", "op");
    }
};

当前正在开发没有这种问题的新MultiSelect插件(请参阅更多信息 GitHub 下载新的Beta版本.在我最近的

Currently the new MultiSelect plugin are developing which has no such problems (see more information here). You can download new beta version from GitHub. In my recent answer I included the demo which used the new plugin.

这篇关于jqGrid搜索运算符未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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