ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Grid paging counts do not properly update when dynamically adding/removing rows

Open cutterbl opened this issue 9 years ago • 4 comments

There are tutorials on how to dynamically add and remove rows from a grid, each revolving around updating the 'data' array in grid options. This works beautifully for including new rows of data, or removing rows, without having to make additional requests of the server to 'reload' the grid. The only issue is that pagination counts are not updated when changes are made.

For instance, if I have a grid with a total count of 55 records, and I'm displaying items 1 to 25, and I remove a row, then I would expect the total count to be decremented by 1, and the display to now say I'm viewing items 1 to 24. Now, in my method where I remove the array element from data I can also update my options.totalItems easily (manually), but that still doesn't update the '1 or 25' count. Currently that count uses $scope.showingHigh, which is based on a calculation. I can't provide a new value for this without hacking the component, or by changing the paginationPageSize (which would then trigger a reload of the grid). Perhaps the calculation could be changed to use the array length, rather than the paginationPageSize? I know that would be problematic when also doing client side filtering, so I'm not entirely sure of the logic needed...

cutterbl avatar Jun 23 '16 14:06 cutterbl

I am facing the exact same issue. @cutterbl Let me know if you found a workaround for it.

AymanNatsheh avatar Aug 02 '16 09:08 AymanNatsheh

did u get any workaround for this?

meenakshi1969 avatar Mar 27 '18 10:03 meenakshi1969

same issue here!

jacques-hoventer avatar May 18 '18 11:05 jacques-hoventer

I haven't implemented this yet, but this article is kind of talking about the issue and possible solutions https://coderwall.com/p/lkcaag/pagination-you-re-probably-doing-it-wrong

cyurtbil avatar Aug 05 '19 21:08 cyurtbil