Multiple selects (2 part question)
Multiple selects (2 part question)
Hey Guys,
I know I can hold control and select multiple rows. Is there a way around that to where you don't have to hold control?
The table shows the number of rows selected. Is that information put into an array? I've coded below and it works just fine. Just wondering if you have already designed this.
var searchForCheckeds = $("#studentsTab tbody tr.selected").map(function () {
var studentID = $(this).find("td").eq(0).html();
return studentID;
}).get();
Only problem with this is that I have some hidden columns that have the Row ID (which I actually want). This code only grabs what's on the page.
Thanks again,
Tim
This question has accepted answers - jump to:
Answers
Hi @54696d20 ,
Yep, see this example here,
Cheers,
Colin
Thanks @colin. What about the second part?
The table shows the number of rows selected. Is that information put into an array? I've coded below and it works just fine. Just wondering if you have already designed this.
var searchForCheckeds = $("#studentsTab tbody tr.selected").map(function () { var studentID = $(this).find("td").eq(0).html(); return studentID; }).get();
Only problem with this is that I have some hidden columns that have the Row ID (which I actually want). This code only grabs what's on the page.
Thanks again,
Tim
Colin pointed you to the Select Extension which has API's to both get and set selected rows. You can get the selected rows using the API similar to this:
https://datatables.net/extensions/select/examples/api/get.html
Instead of using
count()
you would usedata()
to get the data of all the rows selected.Kevin
Ahh.. Thanks @kthorngren . I was using
.on( 'select', function ( e, dt, type, indexes ) {
var rowData = table.rows( indexes ).data().toArray();
}