I am new to JQuery. Can anyone tell me how to add checkboxes to a jquery dataTable?
A column can be shown with a checkbox that reflects the row's selected status simply through the use of the select-checkbox CSS class for that column ( columns. className ). Row selection can be restricted to that column using the select. selector option.
function uncheckRow(trId) {<br> var table = $('#example'). DataTable(); var row = table. row("#"+trId); var rowData = row. data(); var name = rowData[1]; var age = rowData[2]; // need to check if the check box in the 1st column(rowData[0]) is checked or not, If it is checked, i have to uncheck … }
nodes(); // Check/uncheck checkboxes for all rows in the table $('input[type="checkbox"]', rows). prop('checked', this. checked); }); // Handle click on checkbox to set state of "Select all" control $('#example tbody'). on('change', 'input[type="checkbox"]', function(){ // If checkbox is not checked if(!
I guess you're using the jQuery datatables plugin here:
You can use the aoColumnDefs
parameter to customize a column, like-
aoColumnDefs : [
{
aTargets: [0], // Column number which needs to be modified
fnRender: function (o, v) { // o, v contains the object and value for the column
return '<input type="checkbox" id="someCheckbox" name="someCheckbox" />';
},
sClass: 'tableCell' // Optional - class to be applied to this table cell
}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With