限制jqgrid中的高级搜索 [英] Restricting advanced search in jqgrid

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

问题描述

有什么方法可以限制高级搜索,例如使用户只能在四个条件或更小的条件下进行搜索.

Is there any way to restrict the advanced search like enable the user to search only on four conditions or lesser than that.

推荐答案

实现要求的最简单方法是根据规则数量禁用/启用搜索对话框的添加"按钮.您可以在 afterRedraw 回调中进行更改.如果您具有所有网格的通用要求,则可以在$.jgrid.search中设置afterRedraw回调.代码如下所示:

The easiest way to implement the requirement is to disable/enable "Add" button of the searching dialog based on the number of rules. You can make the changes inside of afterRedraw callback. If you have the requirement as common requirement for all grids you can set afterRedraw callback in $.jgrid.search. The code can looks like the following:

$.extend($.jgrid.search, {
    recreateFilter: true,
    multipleSearch: true,
    multipleGroup: true, // remove the setting if you don't need grouping
    afterRedraw: function () {
        var needBeDisabled = $(this).find(".columns").length >= 4;
        $(this).find(".add-rule,.add-group").each(function() {
            $(this).prop("disabled", needBeDisabled);
        });
    }
});

请参见演示,其中我将规则数量限制为最多两个:

See the demo where I restricted the number of rules to maximal two:

这篇关于限制jqgrid中的高级搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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