Datatable with checkbox, how to get IDs ?
Datatable with checkbox, how to get IDs ?
Daleman
Posts: 17Questions: 5Answers: 0
I have this datatable, http://live.datatables.net/baquqore/1/edit. Each row has unique ID.
How do I get ID if I click the checkbox ? Whether single, multiple selection or all rows.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @Daleman ,
Your ID is just the value in the first column, but because you're over-writing it with a checkbox, it's no longer available. The best bet is to use another hidden column for that ID, as in this example here.
Cheers,
Colin
so, how do I get sequential ID when I click checkbox ?
Even, when I separate ID and checkbox column, It doesn't work.
In your context the checkbox has the only function to select rows. Hence you can use this:
https://datatables.net/reference/api/rows().ids()
Here is more:
https://datatables.net/forums/discussion/30848
If you want the ids in an array use this:
You could also use an event to get the id's whenever something is being selected:
Did you look at the example in my link - it was displaying the data in the console. Here it is again, this time I'm explicitly displaying that ID column in the array:
http://live.datatables.net/baquqore/6/edit
thank's to both of you....