jqgrid default pagination not working with ajax and xml data -
i have created jqgrid follows:
$("#table_jqgrid").jqgrid({ autowidth: true, shrinktofit: true, datatype: function(postdata) { jquery.ajax({ url: 'getxmlinfo', data:postdata, datatype:"xml", complete: function(xmldata,stat){ debugger; console.log(xmldata); if(stat=="success") { var thegrid = jquery("#table_jqgrid")[0]; console.log(thegrid) debugger; thegrid.addxmldata(xmldata.responsexml); } } }); }, colnames: ['col1', 'col2', 'col3', 'col4', 'col5', 'col6'], colmodel :[ {name: 'col1', index: 'col1', width: 60, sorttype: "int"}, {name: 'col2', index: 'col2', width: 90, sorttype: "date"}, {name: 'col3', index: 'col3', width: 100}, {name: 'col4', index: 'col14', width: 80, align: "right", sorttype: "float"}, {name: 'col5', index: 'col5', width: 80, align: "right", sorttype: "float"}, {name: 'col6', index: 'col6', width: 80, align: "right", sorttype: "float"} ], pager: '#pager_jqgrid', loadonce:true, rownum:10, rowlist:[10,20,30], sortname: 'col1', sortorder: 'desc', rowtotal:40, viewrecords: true, });
everything working fine when changing records per page.but pagination not correct. getxmlinfo url servlet function returns corresponding xml ajax response.
initially page number 1 , records/page 10 10 rows shown.is there way set total number of pages in jqgrid?
after long search 1 link revealed there exists option setting rowtotal parameter.but not working .how can persist pagination data on each ajax call.is there exists solution set totalrows on each ajax call.
i strictly recommend don't use datatype
function if need make ajax call server. more 90% of code implements such feature uses in wrong way. code example can send ajax request once in internet explorer because known problem caching of ajax requests. use additionally complete
callback instead of "success"
, not full correctly. "notmodified"
example of successful response too. should never use jquery.ajax
if not real specialist in subject.
you should understated jqgrid able use datatype
function. can find example of implementation in the answer. can see code not short. answer written many years ago , it's not supports many features added in jqgrid later. function datatype
in jqgrid 4.5.3 , later example contains 5 parameters. function addxmldata
try call contains 5 parameters too. current implementation of datatype
break standard callbacks, example loadcomplete
, loaderror
, beforeprocessing
. features of jqgrid virtual scrolling or frozen columns broken too.
i recommend replace datatype
to
url: "getxmlinfo", datatype: "xml"
i recommend additionally remove index
properties colmodel
. use loadonce: true
option require index
, name
value same. use example name: 'col4', index: 'col14'
break rule.
i strictly recommend add gridview: true
option improve performance of loading of grid. should consider use autoencode: true
option if xml data returned server don't contains html fragments need set in cells of jqgrid.
Comments
Post a Comment