gyrocode / jquery-datatables-checkboxes

Checkboxes is an extension for the jQuery DataTables library that provides universal solution for working with checkboxes in a table.
https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
MIT License
150 stars 61 forks source link

Error when using ServerSide. #102

Closed Benjythebee closed 4 years ago

Benjythebee commented 4 years ago

I get the datatable error

Requested unknown parameter '0' for row 0, column 0 ...

When trying to implement checkboxes in the first column with serverside processing. Here is the code var table = $('#table-keys').DataTable({ 'processing': true, 'serverSide': true, 'columnDefs': [ { 'targets': 0, 'checkboxes': { 'selectRow': true } } ], 'ajax': 'post/dt_fingerprint.php', 'select': { 'style': 'multi' }, 'order': [[1, 'asc']] });

And here is the php file dt_fingerprint:

` // Table's primary key $primaryKey = 'id';

// Array of database columns which should be read and sent back to DataTables. // The db parameter represents the column name in the database, while the dt // parameter represents the DataTables column identifier. In this case simple // indexes $columns = array( array( 'db' => 'id', 'dt' => 1 ), array( 'db' => 'name', 'dt' => 2 ), array( 'db' => 'fingerprint', 'dt' => 3 ),

);`

and here is the html file that has the table:

`

ID name fingerprint
` The code works, and by that I mean I get the table to work and the checkboxes to work. However, I constantly get the following error before the table loads. > DataTables warning: table id=table-keys - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4 I realise the error might be due to the extra column (column 0) but I don't know how to tell datatable to ignore it Help I'm currently using these script tags: ` `
Benjythebee commented 4 years ago

I fixed it by adding " 'data':null, " in columnDefs