开发者

Search is not working with filter toolbar in 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...",
            sor开发者_运维技巧table: true,
            altRows: true,
            loadonce: true,
            rowNum: 100,
            pager: '#pager',
            root: "rows",
            rowList: [100, 200, 300],
            pagination: true,
            ignoreCase: true 
        })

Load data at later stage

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
                    });
            }
        }

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.

Any suggestions?


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

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜