When I switched the jqGrid to use the advanced search – it seems to work fine, except it pops up with the above error “TypeError: Cannot read property ‘searchrules’ of undfined” in Chrome when you hit the find button. Weirdly in Firefox the error is: “TypeError: g is undefined”.
If I just click ok to the error, the page posts back to my MVC controller just fine. I just want the error to go – any ideas?
Here is the grid code:
jQuery("#list").jqGrid({
url: '/Audit/GridData/',
datatype: 'json',
mtype: 'GET',
colNames: ['Id', 'Date', 'Username', 'ObjectName', 'Event', 'Module'],
colModel: [
{ name: 'Id', index: 'Id', width: 100, align: 'left', searchrules: { required: true }, search: true },
{ name: 'Date', index: 'DateStamp', width: 100, align: 'left', searchrules: { required: true }, search: true },
{ name: 'Username', index: 'Username', width: 200, align: 'left', searchrules: { required: true }, search: true },
{ name: 'ObjectName', index: 'ObjectType', width: 200, align: 'left', searchrules: { required: true }, search: true },
{ name: 'Event', index: 'Event', width: 120, align: 'left', searchrules: { required: true }, search: true },
{ name: 'Module', index: 'Module', width: 120, align: 'left', searchrules: { required: true }, search: true}],
pager: '#pager',
rowNum: 10,
postData: {
filters: '{"groupOp":"AND","rules":[{"field":"invdate","op":"gt","data":"2007-09-06"},{"field":"invdate","op":"lt","data":"2007-10-04"},{"field":"name","op":"bw","data":"test"}]}'
},
pgbuttons: true,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
imgpath: 'http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/themes/redmond/images/',
caption: 'Audits'
}).navGrid('#pager', { search: true, edit: false, add: false, del: false, searchtext: "Search" }, {}, {}, {}, { multipleSearch: true, sopt: ['eq', 'bw', 'cn', 'gt', 'lt'] });
Thanks
You use very strange value of the
postData.filters. It contains the rules forinvdateandnamefields which are not exist in the grid. I suppose that correct data will be something likeIn any way you should use the values from the
indexproperties of thecolModelwhich you use.Additionally you should remove deprecated option
imgpathwhich will be just ignored by jqGrid having version higher as 3.4.x.