Search in jqGrid

I am a starter in jqGrid, I am writing this code to build jqGrid in ASP.NET

var grid = $('#list'); grid.jqGrid({ url: 'jQGridHandler.ashx', postData: { ActionPage: 'CostTypes', Action: 'Fill' }, ajaxGridOptions: { cache: false }, direction: "rtl", datatype: 'json', height: 490, colNames: ['CostId', 'CostNo', 'CostName', 'Remark '], colModel: [ { name: 'COST_ID', width: 100, sortable: true, search:true, editable: false, hidden: true, key: true, index: 'COST_ID' }, { name: 'COST_NO', width: 100, sortable: true, editable: true }, { name: 'COST_NAME', width: 350, sortable: true, editable: true }, { name: 'REMARK', width: 300, sortable: true, editable: true } ], gridview: true, rowNum: 30, rowList: [30, 60, 90], pager: '#pager', sortname: 'COST_ID', viewrecords: true, rownumbers: true }); grid.jqGrid('navGrid', '#pager', { add: false, edit: false, del: true, search: true }, {}, {}, { url: "JQGridHandler.ashx?ActionPage=CostTypes&Action=Delete", reloadAfterSubmit: false }, { multipleSearch: true}); 

when you click the search icon and show the search box when entering a text example costNo=1 jqGrid does not filter, I think this action does not work, please help me in impregnation search in jqGrid thanks everyone

EDIT 01: when I add loadonce: true search, but when deleting this option the search does not work, please help me. thank

+1
jqgrid jqgrid-formatter
06 Sep
source share
1 answer

If you use loadonce: true , the data will be loaded into the grid once . After that, the datatype will be changed to "local" , and all actions, such as rebooting, sorting, searching (filtering), will be implemented locally without communication with the server.

If the user starts a search in the grid, it will be rebooted. If you use url: 'jQGridHandler.ashx', datatype: 'json' , then a new request will be sent to jQGridHandler.ashx URL. Some additional parameters inform the server that the data should be filtered, the _search parameter will be set to true . Since you are using multipleSearch: true , the rest of the search filter information will be sent by another parameter: filters . This is a JSON string. The format is described in the documentation . Thus, the server must decode the filters parameter and filter the grid data (usually one of them constructs the WHERE part of the SQL SELECT based on the value of the filters parameter).

In the answer you will find a sample code and you can download a demo project .

+2
07 Sep '12 at 10:37
source share



All Articles