'Invert selection' button?
'Invert selection' button?
krychaj5
Posts: 19Questions: 8Answers: 0
Hi!
I'm loooking for code button which will invert selection in my rows.
For example: I have 10 rows, 4 selected / 6 unselected and I need button which will make it 6 selected / 4 unselected.
Is there any solution?
This discussion has been closed.
Answers
You can use the code snippets from the first two
Select API
examples here to create the invert selection button:https://datatables.net/extensions/select/examples/api/index.html
Maybe something like this:
You can use the Datatables buttons as shown in the examples or create your on button with a click event handler.
Kevin
Not working.
Can You help me out with this example?
http://live.datatables.net/buhiseti/1/edit
Start by adding the select extension and setting it as an option during Datatables initialisation.
Kevin's code works fine then.
I've initialized "select extension" and It still not working:
http://live.datatables.net/buhiseti/3/
The extension has to be included.
In addition to adding the code for the select extension you also need to create the
table
variable, something like this:table = $('#example').DataTable( {
You can add the select extension code to your example by clicking
Add Library
.Kevin
Kevin's code looks just about spot on to me. The only thing I would say is to use
rows().indexes()
rather thanrows()[0]
on the first line. This is just the formal way to get the indexes, but really they amount of the same thing in the case of a single table API instance.Allan