Pagination problem in jqgrid with array data

前端 未结 2 1967
深忆病人
深忆病人 2020-12-07 03:44

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(\'

2条回答
  •  天命终不由人
    2020-12-07 04:11

    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:

    • in the definition of the mydata array you should remove ',' before ']'.
    • in the for loop you should use i instead of i<=mydata.length.
    • you should remove from the definition of jqGrid following parameters which are either non existent (like 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).

提交回复
热议问题