I don't think you understand. I'm using the stateSave true option. And so my table has 50 records, 25 per page : 2 pages. If I select 2 records on page 1 and hit the button, it alerts 2. I go to page 2 and select 3 more records then hit the button. Rather than alerting 5 it alerts only 3. if I page back to page 1, again it alerts 2.
Replicating my scenario is a bit tricky as it involves serverSide/ ajax, createdRow, rowCallback entries, kendoUIDatePicker in each line each with onChange events, select and deselect events on the rows and a manual call to row.select() somewhere.
Will look more closely at the code first but if you could give some pointers as to what to examine closer to solving this would be useful.
my scenario is a bit tricky as it involves serverSide
I was thinking that this might be your issue but you mentioned going back to the first page and the two rows are selected. Are you writing these to the DB?
Anyway with serverSide enabled the table.rows( { selected: true } ) is only going to look at what is in the client. In your case that is the page being displayed. If you are saving the checkbox state to a DB then you can query the DB for the items with the checkbox selected. Otherwise maybe you can use an array that contains selected row ID's and removes the rows that are deselected.
server-side processing feature provides a method to let all the "heavy lifting" be done by a database engine on the server-side
When using server-side processing, DataTables will make an Ajax request to the server for each draw of the information on the page (i.e. when paging, ordering, searching, etc.).
Also its noted in the FAQ regarding Buttons and SSP. However you wouldn't run across this using Select.
In most cases it is left to the developer to understand if the process or function used is a client side process. Anything dealing with table data is a client side process except the built-in searching, sorting and paging functions when SSP is enabled.
Answers
The example works for me. You need to hold down control or shift to select multiple items.
As a side note you can change the method for multiple selection:
https://datatables.net/reference/option/select.style
Kevin
I don't think you understand. I'm using the stateSave true option. And so my table has 50 records, 25 per page : 2 pages. If I select 2 records on page 1 and hit the button, it alerts 2. I go to page 2 and select 3 more records then hit the button. Rather than alerting 5 it alerts only 3. if I page back to page 1, again it alerts 2.
Hope this clarifies my need.
Using -option stateSave` doesn't seem to affect getting the row count when going between pages in this example:
http://live.datatables.net/bocogeho/1/edit
Maybe you can update my example with your code so we can see the problem.
Kevin
Well, your jsbin is working exactly as I want.
Replicating my scenario is a bit tricky as it involves serverSide/ ajax, createdRow, rowCallback entries, kendoUIDatePicker in each line each with onChange events, select and deselect events on the rows and a manual call to row.select() somewhere.
Will look more closely at the code first but if you could give some pointers as to what to examine closer to solving this would be useful.
I was thinking that this might be your issue but you mentioned going back to the first page and the two rows are selected. Are you writing these to the DB?
Anyway with
serverSide
enabled thetable.rows( { selected: true } )
is only going to look at what is in the client. In your case that is the page being displayed. If you are saving the checkbox state to a DB then you can query the DB for the items with the checkbox selected. Otherwise maybe you can use an array that contains selected row ID's and removes the rows that are deselected.Kevin
That must be it then! Why the heck didn't anyone say so (in the documentation that is) and save me 2 days of head scratching!?!
It is somewhat implied by the Server Side docs:
Also its noted in the FAQ regarding Buttons and SSP. However you wouldn't run across this using Select.
In most cases it is left to the developer to understand if the process or function used is a client side process. Anything dealing with table data is a client side process except the built-in searching, sorting and paging functions when SSP is enabled.
Kevin