jqGrid paging question

2018-12-31 14:06发布

问题:

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).

回答1:

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.