搜索不适用于JQGrid中的过滤器工具栏

时间:2011-04-04 08:16:55

标签: search jqgrid

我面临的问题是在JQGrid的后期代替在停止网格时代替数据。我正在使用过滤器工具栏进行搜索。

以下是我使用的代码:

创建网格

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,则搜索效果很好。

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

方法addJSONData不能用于处理具有'local'数据类型的jqGrid。

您可以使用addRowData并使用localReader代替jsonReader或使用data方法设置jqGrid的setGridParam参数,然后调用{{ 1}}(见here)并重新加载网格。