Select all table rows from all pages (not only current page data)
Select all table rows from all pages (not only current page data)
Hi,
I have created a select all button using datatables. Also, I loaded data table with values using Ajax.
Then, I tested select all button functionality and I realised an issue: it selects only the current page data.
As I saw, similar cases were solved using: initComplete, serverside:true, {page:"all"} or select:true, but any of these options solved my issue.
Finally, code side, I selected all table rows using "table.rows().select();"
Does anyone have a previous experience on this?
Answers
Yes, it's simple, isn't it? I got one, too. But I want a potential search filter applied.
By the way data tables has its own selectAll and its own selectNone button.
If I recall it correctly I didn't like the built-in selectAll button and hence created my own. But I use the built-in selectNone button.
You would need to take care of the language defaults if you use languages other than English.
This is the code of the built-in buttons:
Thank you for the response.
I tried selectAll and selectNone buttons (i.e. not built-in buttons) as well, but I got the same problem. Meaning that, only table rows of the current page are selected.
@rf1234 In your case, do you use ajax? I think there are restrictions on row selection when use ajax data source.
I use Editor with ajax.
selectAll can only select what was downloaded to the client. In case you use server side processing you are probably only loading the current page to the client. At least that would be Editor's behavior.
In that case: Turn off paging or turn off server side so that all records get downloaded to the client.
(Server side is hardly ever needed by the way. Many people turn it on without needing it. I would turn off server side first.)
P.S.: Hard to help without seeing any of your code Guesswork ...
@adrdgr did you find how to do it?
@adrdgr See my answer in your other thread.
Kevin