Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding checkboxes to jquery datatable [closed]

I am new to JQuery. Can anyone tell me how to add checkboxes to a jquery dataTable?

like image 235
Lalit Avatar asked Sep 26 '12 07:09

Lalit


People also ask

How to add checkbox in DataTable column?

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.

How check checkbox is checked or not in jquery DataTable?

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 … }

How do I select all checkboxes from all pages in jquery DataTable grid?

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(!


1 Answers

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
}]
like image 193
Vishal Avatar answered Oct 04 '22 12:10

Vishal