搜索数据为空 [英] Searching data is null

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

问题描述

我正在使用jqGrid 4.6,但我也在最新版本5.1.0上尝试过此操作. 我对searchoptions有这样的定义:

I am using jqGrid 4.6, but i laso tried this on latest version 5.1.0. I have such definition of searchoptions:

loadComplete: function() {
    var keys = grid.getGridParam('colModel');
    for (var i=1; i<keys.length; i++) {
        var cellname = keys[i].name;
        grid.setColProp(cellname, {
            searchoptions: {                
                dataUrl: 'RData_io.php?action=filter&field=' + cellname,
                sopt: ['eq', 'ne', 'lt', 'gt', 'le', 'ge', 'cn', 'nc'],
                postData: grid.getGridParam('postData')
            }
        });
    }       
}

dataUrl为我提供了正确的选择,并且经过一小段时间后,值已正确加载到dropdownbox中. 我们得到这样的东西:

dataUrl gives me correct select, and value is loaded correctly inside dropdownbox after some small amount of time. We get something like this:

看起来不错,但是,当我们单击查找"按钮时,我们已将以下参数发布到服务器:

Seems fine, but, when we click the "Find" button, we have such params posted to the server:

filters:"{"groupOp":"AND","rules":[{"field":"week1","op":"eq","data":null}]}"

因此,如您所见,"Pass"未发布到服务器.好的,如果我们更改为失败",然后又返回通过",则表示一切正常.

So, as you can see, "Pass", is not posted to server. Altough, if we change to "Fail", and then back to "Pass" - it's working fine.

Oleg ,您能帮我吗?

谢谢你, 扎克哈尔

更新:如果不是使用Oleg的Free-jqGrid,而是使用某些旧版本或< = 5.1.0.您可以使用此技巧,与@Oleg提出的技巧相同,但由于selectFilled不允许您使用option,请改用此技巧:

UPDATE: If you are using not Free-jqGrid from Oleg, but some old version, or <= 5.1.0. You can use this trick, something same as @Oleg proposed, but as selectFilled do not let you to use option, use this instead:

selectFilled: function (options) {
    $('.input-elm').change();
},

推荐答案

我在演示中看到了问题.这是jqGrid中的错误.感谢您的错误报告!

I see the problem on the demo. It's a bug in jqGrid. Thank you for the bug report!

我将在明天修复它,但是仍然可以使用免费的jqGrid的其他功能作为解决方法.可以使用selectFilled回调,该回调在dataUrl

I'll fix it tomorrow, but one can still use an additional feature of free jqGrid as the workaround. One can use selectFilled callback which trigger change event after the select is successfully loaded from dataUrl

selectFilled: function (options) {
    $(options.elem).change();
}

相应的searchoptions选项如下所示:

searchoptions: {
    clearSearch: false,
    selectFilled: function (options) {
        $(options.elem).change();
    },
    dataUrl: '/echo/html/',
    sopt: ['eq', 'ne', 'lt', 'gt', 'le', 'ge', 'cn', 'nc'],
    postData: { 
        html: "<select><option>Pass</option></select>",
        delay: 0
    }
}

一个人可以验证固定演示是否在过滤器rules中使用正确的data: https: //jsfiddle.net/OlegKi/mxct4bdu/7/

One can verify that the fixed demo use correct data in the filter rules: https://jsfiddle.net/OlegKi/mxct4bdu/7/

更新:我已修复GitHub源上的错误(请参见提交).现在,没有使用selectFilled: function (options) { $(options.elem).change(); }的解决方法的演示可以正常工作.参见 https://jsfiddle.net/OlegKi/mxct4bdu/8/

UPDATED: I fixed the bug on GitHub sources (see the commit). Now the demo without the workaround with selectFilled: function (options) { $(options.elem).change(); } works correctly. See https://jsfiddle.net/OlegKi/mxct4bdu/8/

这篇关于搜索数据为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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