vendredi 30 septembre 2016

Use row.add for datatable with checkboxes

I have the following code that I am using to populate and generate rows for a checkbox datatable:

    var array = [...];
    $datatable = $('#datatable-checkbox');

    // checkboxes
    $datatable.dataTable({
      'order': [[ 1, 'asc' ]],
      'columnDefs': [
        { orderable: false, targets: [0] }
      ]
    });

    for(int i in array) {
        var name = array[i][0];
        var message = array[i][1];
        var num = array[i][2]; 

        $datatable.DataTable().row.add([
            name,
            message,
            num
        ]).draw( false );
    }

However, the first data field in the row (name) seems to replace the checkboxes as if the rows were empty.

My question is, is there a way to add data to a row while ignoring the first column? Or to add checkboxes back to the first column?




Aucun commentaire:

Enregistrer un commentaire