-
Notifications
You must be signed in to change notification settings - Fork 8
Row Selection is not consistent when we navigate between pages. #9
Comments
From @c0bra on April 7, 2015 21:47 @pandey-mohit This is ng-grid (v2.x) and will be superseded by UI-Grid (3.x) in the near future. Here's a quick plunker showing selection + pagination in 3.x: http://plnkr.co/edit/qoEQd6F6qHvGwrrUrIzp?p=preview |
From @pandey-mohit on April 8, 2015 4:23 @c0bra : I already implemented ng-grid in our current project and its harder to switch to ui-grid. Is there any quick-fix for it? |
From @c0bra on April 8, 2015 16:6 @pandey-mohit There may be a fix, but I'm not aware of one; sorry! I was never involved in the 2.x pagination stuff. |
From @tzweiner on April 21, 2015 22:19 @c0bra: can you show an example with server-side pagination? I'm experiencing the exact same issue on ui.grid 3.0.0 rc20. Your plunker is using standard pagination, and it works just fine. However, I'm using external pagination and I'm seeing the exact behavior that pandey-mohit described above. |
From @pandey-mohit on April 22, 2015 5:42 @tzweiner : I solve the above issue by adding "primaryKey" property to gridOptions. You need to pass a unique field to it. Example: In it, "id" is your unique field, you can assign it as a primary key "primaryKey: 'id'". It will solve the above mentioned issue (in my case, it works like a charm). Also, "primaryKey" field is never mentioned in ng-grid documentation but i read about it in another open issue raised for row selection problem. |
From @tzweiner on April 22, 2015 12:47 Yes, I did read about primaryKey and included it. This is what I've included in my gridOptions: I still get the unwanted behavior of Selected Items remembering an obsolete count after paging (via external pagination). |
From @pandey-mohit on April 22, 2015 12:55 Please create an example (http://jsfiddle.net/) for it. |
From @tzweiner on April 22, 2015 14:26 I tried Plnkr but as soon as I add in ui-grid it blanks out. |
From @tzweiner on April 22, 2015 16:3 @pandey-mohit I forked @c0bra 's plnkr which uses ui-grid and take a look here Select some rows on page 1, then go to next page, come back to page 1. Nothing there is selected but Selected Items keeps showing the old count and when you select more rows, the count is incremented in a way that does not correspond to the number of selected rows. This uses primaryKey. |
From @tzweiner on April 22, 2015 16:10 This is essentially happening because with External Pagination we are loading new data every time. So we lose track of any row properties (such as "selected") when we load in the new page data. We probably need to maintain a record of what's been selected separately in a service or something and then select manually any rows that were previously selected. I still think that there's something wonky about Selected Items tho. It should show 0 after you load another set of rows, or remember internally which rows were previously selected when you come back to a page with already selected rows. |
From @PaulL1 on April 22, 2015 17:56 Expected behaviour for ui-grid based on looking at the code is that:
|
From @tzweiner on April 23, 2015 18:11 Yes, that was the conclusion I arrived at too. I ended up saving any checked off rows in a service and then selecting them back manually once we bring them back into the result set. I had to remove this tho: 'showGridFooter: true' because it was causing Selected Items in the footer to show the wrong count. I implemented my own counter for that as well. |
From @syoon7575 on July 9, 2015 22:18 @tzweiner I have the exact issue with external pagination. I tried saving the selected rows and re-selecting inside "on.paginationChanged" function, but it selects the previous page's row. When the pagination is complete, the grid refreshes and removes all selection again. |
From @nivek91 on July 24, 2015 15:30 +1 , how did you solve this? |
From @syoon7575 on July 24, 2015 19:18 @nivek91 You could check out http://ui-grid.info/docs/#/tutorial/208_save_state this But how I solved this is:
|
Yes I did Make it work with keeping a separate selected array in the scope
|
From @pandey-mohit on April 7, 2015 10:33
This link is present in your officical site under "Server-Side Paging Example"
http://plnkr.co/edit/50vJrs?p=preview
Steps to reporduce:
Copied from original issue: angular-ui/ui-grid#3224
The text was updated successfully, but these errors were encountered: