Add Checkbox to datatables
Add Checkbox to datatables
johngtrs
Posts: 33Questions: 2Answers: 0
Hi,
I'm server side I want to add a checkbox who returns true or false when the checkbox is checked or not. But I don't know how to add the event on change to my checkbox in the table and send the boolean to my data. And I want to set the checkbox next to the global search.
//--- JQUERY ---
$(document).ready(function() {
$('#searchlog').DataTable({
serverSide: true,
aaSorting: [[1, 'desc']],
ajax: {
url: '/mypath/...',
method: 'POST',
data: {
caseSensitive: true // I want the checkbox's return on this parameter
}
}
});
$('#idCaseSensitive').change(function(data) {
if(this.checked) {
return true;
}else{
return false;
}
});
});
//--- HTML ---
<table id="searchlog" class="table table-striped table-bordered" cellspacing="0" width="100%">
Case Sensitive : <input type='checkbox' id='idCaseInsensitive' />
<thead>
<tr>
<th>COL1</th>
<th>COL2</th>
<th>COL3</th>
<th>COL4</th>
<th>COL5</th>
<th>COL6</th>
<th>COL7</th>
<th>COL8</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Could you help me to do that please?
Thanks in advance.
This discussion has been closed.
Answers
Up please.
How can I add a method to my datatable variable before .draw() ?
I solved my issue with a function who returns the flag variable and I use it in the data caseSensitive.