Forum
22:33
07/04/2014
//load the empty grid
jQuery("#customerResults").jqGrid({
datatype: 'local',
loadonce:true,
colNames:[ 'Address'],
colModel:[ {name:'addrLineTxt',index:'addrLineTxt', editable:false}],
autowidth:true,
height: 'auto',
rowList:[],
pgbuttons:false,
pgtext:null,
viewrecords: true,
pager: '#customerResultPager',
caption:"Customer Search Result",
shrinkToFit: true,
});
jQuery("#customerResults").jqGrid('navGrid','#customerResultPager',{search:false, add:false, edit:false, del:false}, {}, { }, {}, {} );
//This is event for external form to refresh grid based on certain search criteria.
$("#customerSearchForm").submit(function (e) {
e.preventDefault();
$.ajax({
type:"post",
data: $('form:first').serialize(),
url: $('form:first').attr('action'),
success: function(response){
$('#customerResults').jqGrid('clearGridData');
$('#customerResults').jqGrid().setGridParam({ data: response.rows, datatype:'json', }); //Everything fine till this line. And response.rows has records.
$("#customerResults").jqGrid().trigger("reloadGrid", [{page:1} ]); } }); //This line causes the page to refresh so that Insted of grid with data I see the fresh grid.
//I see 2 calls made to the server. one to post the result and another one the url of the page containing grid. If I comment trigger("reloadGrid"), I only see one call to server but the data is not refreshed on the grid.
});
23:49
07/04/2014
Haha found the solution myself:
$("#customerSearchForm").submit(function (e) {
e.preventDefault();
$('#customerResults').jqGrid().setGridParam({
url: $('form:first').attr('action'),
postData: $('form:first').serialize(),
datatype:'json',
jsonReader : { root: "rows", page: "page", total: "total", }
}).trigger("reloadGrid", [{page:1} ]);
});
Most Users Ever Online: 715
Currently Online:
36 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66