i'm starter in jqGrid, i write this code for 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 click in search icon and show search box when enter text example costNo=1 jqGrid not filter i think this action no work, please help me for implimet search in jqGrid
thanks all
EDIT 01: when i add loadonce: true search work but when remove this option search don't work, please help me. thanks
If you use
loadonce: truethe data will be loaded in the grid once. After that thedatatypewill be changed to"local"and all actions like reloading, sorting, searching (filtering) will be implemented locally without communication with the server.If the user start searching the grid will be reloaded. If you use
url: 'jQGridHandler.ashx', datatype: 'json'then the new request will be sent to the URLjQGridHandler.ashx. Some additional parameters inform the server that the data should be filtered, the_searchparameter will be set totrue. Because you usemultipleSearch: truethe rest information about the searching filter will be send in another parameter:filters. It's a string in JSON format. The format is described in the documentation. So the server have to decode thefiltersparameter and filter the grid data (typically one constructsWHEREpart of theSELECTSQL statement based on the value of thefiltersparameter).In the answer you will find the code example and can download the demo project.