Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

jquery - jqGrid paging question

If you have 17 records and are displaying 15 at a time then when you're on page 2 you see records 16-17 of 17 - makes sense.

Now when you're on this second page and you hit the reload button on the nav (set datatype='json') when the grid reloads the nav is showing that the grid is displaying 16-30 of 17. This seems to be a bug - is there a workaround?

The grid still has 17 rows - but it's trying to show a full 15 rows (the rowNum) setting on the second page when it should only be showing two rows (16-17). And the nav pagination text is incorrect (referring to 30 rows when there is only 17).

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are right. It is an old problem. I used always before

$("#list").setGridParam({page:1}).trigger('reloadGrid');

but there is another way. The trigger 'reloadGrid' support additional options: 'current' and 'page'.

$("#list").trigger("reloadGrid", [{page:1}]);

will reset page to 1 in one step. The usage in the form

$("#list").trigger("reloadGrid", [{current:true}]);

allows to preserver current selection. You can of cause combine both options.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...