Reputation: 949
I have a datatable with some rows, table footer is used to filter the data on datatable. I want to create a select button which can select/deselect only filtered results i.e. select the checkboxes from the first column of filtered results only. Have used simple HTML here, it looks something like this:
<html>
<body>
<p>
<input type="button" id="select" value="Select">
</p>
<table>
<tr>
<th>#</th>
<th>ID</th>
<th>Name</th>
</tr>
<tr>
<td><input type="checkbox" id="120"></td>
<td>120</td>
<td>abc</td>
</tr>
<tr>
<td><input type="checkbox" id="119"></td>
<td>119</td>
<td>xyz</td>
</tr>
<tr>
<td></td>
<td><input type="textbox"></td>
<td><input type="textbox"></td>
</tr>
</table>
</body>
</html>
Upvotes: 2
Views: 1425
Reputation: 719
you can get the filtered rows by using:
var rows = $(".datatable").dataTable().$('tr', {"filter":"applied"});
then you can iterate each row and apply what you need check https://datatables.net/forums/discussion/18375/get-all-filtered-rows-across-all-pages for more info
Upvotes: 3