When a checkbox is unchecked, get the row value
When a checkbox is unchecked, get the row value
santosh.sahoo@devoteam.com
Posts: 9Questions: 4Answers: 0
Hello,
I have a simple datatable with datatable.js and datatable select.js
After initialization, I have all the checkbox checked.
What I need is to get the details(values) of the row that the user unchecks. Is there an easy way to do this?
I have the following code:
HTML:
<table id="hrm_search_attachment_list" class="display wrap" width="100%">
<thead>
<tr>
<th></th>
<th>FileName</th>
<th>Type</th>
<th>Filetype</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>FileName</th>
<th>Type</th>
<th>Filetype</th>
</tr>
</tfoot>
<tbody id = 'hrm_result_att'>
<tr>
<td></td>
<td>CV</td>
<td>something1</td>
<td>Senior Developer</td>
</tr>
<tr>
<td></td>
<td>CV2</td>
<td>something</td>
<td>Senior Developer</td>
</tr>
</tbody>
</table>
Javascript:
var hrm_attachment = $('#hrm_search_attachment_list').DataTable({
"lengthMenu": [
[5, 10, 25, 50],
[5, 10, 25, 50]
],
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
select: {
style: 'os',
selector: 'td'
},
initComplete: function() {
this.api().rows().select();
},
order: [[ 1, 'asc' ]]
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can find the code here jsFiddle
You can use the Select extension
deselect
event.Kevin
Thanks @kthorngren
Thats exactly what I needed.
Here is the final javascript: