Adding more than 12 columns
Adding more than 12 columns
I have no problems with up to 12 columns. I can view them all. However, when I add 13 or more columns, I get the error "DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1". How can I add 13 or more columns?
html
`
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 | Column 8 | Column 9 | Column 10 | Column 11 | Column 12 | Column 13 |
---|
****Javascript****
var table = $('#example').DataTable( {
processing: true,
serverSide: true,
ajax: 'serverside/ajax.php',
columns: [
{ data: 'column1' },
{ data: 'column2' },
{ data: 'column3' },
{ data: 'column4' },
{ data: 'column5' },
{ data: 'column6' },
{ data: 'column7' },
{ data: 'column8' },
{ data: 'column9' },
{ data: 'column10' },
{ data: 'column11' },
{ data: 'column12' },
{ data: 'column13' }
],`
ajax.php
$columns = array(
array( 'db' => 'column1', 'dt' => 'column1' ),
array( 'db' => 'column2', 'dt' => 'column2' ),
array( 'db' => 'column3', 'dt' => 'column3' ),
array( 'db' => 'column4', 'dt' => 'column4' ),
array( 'db' => 'column5', 'dt' => 'column5' ),
array( 'db' => 'column6', 'dt' => 'column6' ),
array( 'db' => 'column7', 'dt' => 'column7' ),
array( 'db' => 'column8', 'dt' => 'column8' ),
array( 'db' => 'column9', 'dt' => 'column9'),
array( 'db' => 'column10', 'dt' => 'column10'),
array( 'db' => 'column11', 'dt' => 'column11'),
array( 'db' => 'column12', 'dt' => 'column12'),
array( 'db' => 'column13', 'dt' => 'column13')
);
Answers
There is no limitation in Datatables for the number of columns. The place to start is to use the troubleshooting steps at the link provided in the error:
http://datatables.net/tn/1
Let us know what you find.
Kevin
The problem was in the money column. I was able to list all other fields. I have a str replace function for the money symbol, but I couldn't implement it.
Data
£4,424
£10,242
€15,000
€1,500
Have the server send just a plain number and then use the number renderer to format it for currency display.
Allan