primefaces / primeui

Rich set of javascript-css only widgets
http://www.primefaces.org/primeui
278 stars 125 forks source link

Calling DataTable "reload" after data source update prevents page count updates #236

Open ritchiecarroll opened 8 years ago

ritchiecarroll commented 8 years ago

If you modify the total number of rows in your data source (e.g., by adding or deleting) and update the paginator to properly reflect new state (e.g., by updating new record count by calling "setTotalRecords" method) - then subsequent call to the "reload" method on the data table causes the paginator to get reset to its initial pageCount state preventing access to newly added items and leaving empty pages for deleted items.

http://jsfiddle.net/ritchiecarroll/9ez9njwd/

A work around exists by manually setting page back to zero after "setTotalRecords" call and not calling "reload" method, e.g.: $('#tblremotelazy').puidatatable('getPaginator').puipaginator('setPage', 0);

sfisque commented 5 years ago

you can call "filter" or "sort" on the datatable and that will cause it to reload (refetch if using remote data function). this only works, though, if you have filtering or sorting enabled. otherwise it quietly fails. it is a dirty workaround, but it does work.