0

I got a grid, with checkboxes plugin and Pagination.

I can get selected rows only for the current page I'm at, but not of all the rows. How one can do that?

I search the code, tried finding the global array slickgrid is taking the selected rows when it enters a new page (dataView.syncGridSelection(grid, true)), but didn't manage doing so till now...

Thanks for any help.

ganeshk
  • 5,583
  • 3
  • 27
  • 31
neoswf
  • 4,730
  • 6
  • 39
  • 59

1 Answers1

2

You can subscribe to the onPagingInfoChanged event - which gets triggered when you navigate to a new page - then store the selected rows from that page into a global array for your reference.

dataView.onPagingInfoChanged.subscribe(function(e,pagingInfo) {
  console.log(grid.getSelectedRows());
  // add selected rows to a global array
}

Note: further to what you mentioned, the grid.getSelectedRows() returns the row number relative to the visible rows. So rows on page 2 will start with 0. I would advise to instead get the id of the row and store that in the global array instead (you know, the one each row in the dataview should have and which is unique).

Hope this gives you a start. Let me know if this helps!

ganeshk
  • 5,583
  • 3
  • 27
  • 31
  • 1
    Thats exactly what I did. I am listening to onSelectedRowsChanged event, and populating a global array from there. Thanks for your answer & help. I do think that this behaviour needs to enter the fw. Developers do need to hold in hand the global list, in order to run bulk operations. – neoswf Jul 19 '12 at 14:56
  • The reason I'm checking on every checkbox click, is to enable or disable a bulk operation button. User can always deselect all checkboxs before switching a page. – neoswf Jul 19 '12 at 15:13
  • You are most welcome! SlickGrid by design is meant to keep only visible rows in memory - I think this is what makes it so fast. I think that's the reason it was implemented this way. Fun to play around though - and we do have workarounds for our special needs! :) – ganeshk Jul 19 '12 at 15:24