删除搜索运算符(AND / OR)在multiplesearch的jqGrid [英] Remove search operator (AND/OR) in multiplesearch jqGrid

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

问题描述

我需要隐藏在搜索弹出操作,但我不能得到它的工作。
我想这一点,但无论是运营商还是会出现:

I need to hide the operator in the search popup, but I cannot get it to work. I tried this, but both operators still appear:


jQuery("#grilla").navGrid("#paginador",
{del:false,add:false,edit:false},{},{},{},{
groupOps: [{ op: "OR", text: "any" }], multipleSearch:true});

任何想法?
谢谢!

Any ideas? Thanks!

推荐答案

有没有其他选择,可以直接做你的需要。此外,如果你想躲在里面的 beforeShowSearch 事件处理)与 $('select.opsel')。隐藏() select元素会被隐藏<强>才刚刚开始即可。在任何按钮,用户点击后,对话框会包含不调用任何事件处理程序,并选择元素将再次被看见重绘。

There are no option which can directly do what you need. Moreover if you would hide the ADD/OR operand from the searching dialog at the dialog initialization (for example inside of beforeShowSearch event handler) with $('select.opsel').hide() the select element will be hidden only at the beginning. After the user click on any button the dialog contain will be repaint without calling of any event handler and the select element will be again visible.

所以我建议用覆盖方法的重绘过滤器对话框。在code这这样做可以像

So I suggest to solve the problem with overwriting the method reDraw of the filter dialog. The code which do this can look like

jQuery("#grilla").jqGrid("navGrid","#paginador",
    {del: false, add: false, edit: false}, {}, {}, {},
    {
        multipleSearch: true,
        beforeShowSearch: function($form) {
            var searchDialog = $form[0],
                oldrReDraw = searchDialog.reDraw, // save the original reDraw method
                doWhatWeNeed = function () {
                    // hide the AND/OR operation selection
                    $('select.opsel', searchDialog).hide();

                    setTimeout(function () {
                       // set fucus in the last input field
                       $('input[type="text"]:last', searchDialog).focus();
                    }, 50);
                }
            searchDialog.reDraw = function () {
                oldrReDraw.call(searchDialog);    // call the original reDraw method
                doWhatWeNeed();
            }
            doWhatWeNeed();
        }
    }
);

您可以在的演示该方法确实有效。

You can see on the demo that the way really works.

更新时间::答案书写后,我发布了一些建议,以trirand改善的jqGrid。现在的jqGrid有许多功能,它简化了上述工作。比如有其存在可以直接用 afterRedraw 回调。因此,从答案code看起来像

UPDATED: After writing of the answer I posted some suggestions to trirand to improve jqGrid. Now jqGrid has many features which simplify the above work. For example there are exist afterRedraw callback which can be directly used. So the code from the answer will look like

grid.jqGrid("navGrid", "#pager",
    {add: false, edit: false, del: false}, {}, {}, {},
    {
        multipleSearch: true,
        afterRedraw: function (p) {
            var $form = $(this);
            $form.find("select.opsel").hide();
            setTimeout(function () {
               // set fucus in the last input field
               $form.find('input[type="text"]:last').focus();
            }, 50);
            $form.find("input.add-rule,input.delete-rule").button();
        }
    }
);

看到修改后的演示这里

我增加了一个行 afterRedraw

$form.find("input.add-rule,input.delete-rule").button();

只有提高按钮,在搜索对话框的外观。我建议作出的jqGrid这样的设置默认,但没有被接受trirand。在这样大家任谁包括jQuery用户界面可在 afterRedraw 添加这样的行,使按钮持平。

only to improve the look of buttons in the Searching Dialog. I suggested to make such settings default in jqGrid, but this was not accepted by trirand. In any way everyone who includes jQuery UI can add such line in afterRedraw to make the buttons flat.

这篇关于删除搜索运算符(AND / OR)在multiplesearch的jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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