Saleemuddin Mewati
Saleemuddin Mewati

Reputation: 23

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...",
            sortable: 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?

Upvotes: 2

Views: 4442

Answers (1)

Oleg
Oleg

Reputation: 221997

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.

Upvotes: 2

Related Questions