JqG​​rid-使用其他字段进行简单搜索 [英] JqGrid - Simple Searching With Additional Field(s)

查看:88
本文介绍了JqG​​rid-使用其他字段进行简单搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jqgrid并启用了简单搜索.我想知道是否有一种方法可以在网格的列中不存在的字段选择列表中添加其他项.我将其称为任何字段"之类的名称,以便我可以搜索任何字段,然后处理该结果服务器端.

I am using jqgrid and have simple searching enabled. I am wondering if there is a way to add an additional item in the select list of fields that does not exist as a column in the grid. I would call it something like 'Any Field' so I could search on any of the fields and then handle that outcome server side.

推荐答案

Bethrezen建议使用一个隐藏列是您可以使用的一种方法.您只应该不要忘记使用searchhidden: true 搜索选项.

The suggestion of Bethrezen with the usage of one hidden column is one way which you can use. You should only don't forget to use searchhidden: true searchoptions.

我可以建议您在演示:

在演示中,我添加了

var defaultFilters = {
        "groupOp": "AND",
        "rules": [
            { "field": "All", "op": "cn", "data": ""}
        ]
    };
...
$('#list').jqGrid('navGrid', '#pager', {add: false, edit: false, del: false},
    {}, {}, {},
    {
        multipleSearch: true,
        overlay: 0,
        onInitializeSearch: function ($form) {
            $form.jqFilter('addFilter', defaultFilters);
        },
        afterRedraw: function (p) {
            if (p.columns.length === $("#list")[0].p.colModel.length) {
                p.columns.push({
                    name: 'All',
                    label: 'Any Field',
                    searchoptions: {},
                    searchrules: {},
                    searchtype: 'string',
                    inputtype: 'text'
                });
            }
            //$(this).find('.delete-rule:first').hide();
        }
    });

在演示中,我扩展了jqFilter方法的p.columns参数,并带有附加的伪列"任何字段".我只是希望您可以采用它来满足您的确切要求.

In the demo I extended the p.columns parameter of jqFilter method with and additional "pseudo column" 'Any Field'. It's just the idea which you can I hope adopt to your exact requirements.

这篇关于JqG​​rid-使用其他字段进行简单搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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