I am facing problem with pagination in jqgrid with array data having 18 records, but the records are not displaying in pages even I specified pagination:true,pager:jQuery(\'
Oleg is correct. Adding jQuery("#list4").setGridParam({ rowNum: 10 }).trigger("reloadGrid"); works.
Although it might not work if formatter property is set where the rowObject values will be undefined.(if they are used)
Therefore make sure in your formatter method u always check for their availability.
e.g.
function getFormattedFileName(cellvalue, options, rowObject) {
if(!rowObject.fileName) {// this is due to ...trigger("reloadGrid");
return cellvalue; // the value is already formatted, let's just return it
}
return rowObject.fileName.trim();
}
You main problem is you should reset rowNum
after the adding the large number of rows. The line
jQuery("#list4").setGridParam({ rowNum: 10 }).trigger("reloadGrid");
at the end of your code will fix the problem. I recommend you to add the line
jQuery("#list4").jqGrid('navGrid','#pager1',{edit:false,add:false,del:false});
directly after the definition of the jqGrid. You will then have not only data paging, but also data filtering (searching) and refresh (reset filter).
Some more small remarks:
mydata
array you should remove ',' before ']'.i<mydata.length
instead of i<=mydata.length
.pagination
) or have no sense in the context (like loadonce: true
): pagination
, page
, loadonce
, totalpages
, totalrecords
, showpage
, imgpath
.You receive the best results if you constructs jqGrid with respect of data: myData
parameter, or set all data from mydata
at once (see description of addRowData
method in http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#array_data).