I am facing problem when i refresh a jqgrid. Tried many things but still no solution. I want to refresh the grid after getting json data from server side. Here is what i am doing for refreshing jqgrid.
$("#searchButton").on("click",function(){
var url = contextPath+"/patient/fetchPatients?firstName="+$("#firstName").val()+"&lastName="+$("#lastName").val()+"&diagnosis="+$("#diagnosis :selected").val();
jQuery("#searchedPatientGrid").setGridParam({datatype:'json',url:url}).trigger('reloadGrid');
});
Here is my code for jqgrid config.
jQuery("#searchedPatientGrid").jqGrid({
datatype: "json",
colNames:['id','Firsr Name','Last Name','MObile Number','Action'],
colModel:[
{name:'id',index:'id', width:100},
{name:'firstName',index:'firstName', width:100},
{name:'lastName',index:'lastName', width:100},
{name:'mobileNumber',index:'mobileNumber', width:100},
{name:'operationDetails.operationDone',index:'operationDetails.operationDone', width:100}
],
rowNum:10,
rowList:[10,20,30],
pager: '#gridPager',
sortname: 'id',
"width":"900",
"gridview":true,
viewrecords: true,
sortorder: "desc",
loadonce: false,
caption:"Patient Search Result"
});
When i hit the button for first time it hits the server and loads data in grid, but when i hit the search button again it does not hit the server for the data. I dont know why is this happening.Even i have mentioned in config, loadOnce : false. then it should hit the server if i hit the search button.