搜索不适用于JQGrid中的过滤器工具栏 [英] Search is not working with filter toolbar in JQGrid

查看:65
本文介绍了搜索不适用于JQGrid中的过滤器工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在稍后的阶段在JQGrid中查找数据而不是终止网格时遇到了问题.我正在使用过滤器工具栏进行搜索.

I am facing issue while loaidng the data in JQGrid at a later stage in place of at the time of ceating grid. I am using filter toolbar for search.

以下是我正在使用的代码:

创建网格

following is the code I am using:

Creating Grid


jQuery("#list").jqGrid({
            datatype: 'local',
            colNames: [my col names],
            colModel: [my col model],
             jsonReader: {
                root: "rows",
                page: "page",
                total: "total",
                //records: "records",
                repeatitems: false
            },
            height: 300,
            viewrecords: true,
            gridComplete: this.onGridComplete,
            ondblClickRow: this.rowDblClick,
            onSelectRow: this.selectRow,
            headertitles: false,
            loadtext: "Loading...",
            sortable: true,
            altRows: true,
            loadonce: true,
            rowNum: 100,
            pager: '#pager',
            root: "rows",
            rowList: [100, 200, 300],
            pagination: true,
            ignoreCase: true 
        })

稍后加载数据


if(gridDataStr != "none") // gridDatStr has data 
        {
            grid.initialize(); // create the grid
            var myjsongrid = JSON.parse(gridDataStr);            
            grid.table[0].addJSONData(myjsongrid);  
            grid.table.jqGrid('setGridParam',{datatype:'json', data:myjsongrid}).trigger('reloadGrid');          
            if (myjsongrid["rows"].length > 1) 
            {
                grid.table.filterToolbar({
                    stringResult: true,
                    searchOnEnter: false
                    });
            }
        }

但是,如果在创建数据类型为json的网格并使用一些有效的URL时加载相同的数据,则搜索效果很好.

However if I load the same data at the time of creating the grid with datatype:json and using some valid url, searching is working well.

有什么建议吗?

推荐答案

方法addJSONData不能用于具有本地"数据类型的jqGrid.

The method addJSONData can not be used to work with the jqGrid having the 'local' datatype.

您可以使用addRowData并使用 localReader 代替jsonReader或相对于setGridParam方法设置jqGrid的data参数,然后调用jQuery("#list")[0].refreshIndex()(请参阅

You can use addRowData and to use localReader instead of jsonReader or set data parameter of jqGrid with respect of setGridParam method and then call jQuery("#list")[0].refreshIndex() (see here) and reload the grid.

这篇关于搜索不适用于JQGrid中的过滤器工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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