Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82534

When I open my table, I get an error.

$
0
0

The error is DataTables warning: table id=example - Requested unknown parameter '1' for row 0, column 1. For more information about this error, please see http://datatables.net/tn/4. I know that this has been discussed ad nauseum, but I can't seem to find the magic combination.

My data is an array of objects and is valid JSON:

{
"data": [
{
"DT_RowId": "row_1",
"category": "HTTP Methods",
"test": "API responses MUST use appropriate HTTP status codes.",
"automatable": "Yes",
"priority": "High",
"explanation": "A complete list of codes can be found in the HTTP 1.1 specificataion ."
}, ...

Here's my initialization code:

/* Formatting function for row details - modify as you need */
function format ( d ) {
// d is the original data object for the row
return '

'+ ''+ ''+ ''+ ''+ '
Explanation:'+d.explanation+'

';
}
$(document).ready(function (){
var table = $('#example').DataTable({
'ajax': '../ajax/data/demoObjects.txt',
'columns': [
{
'className': 'details-control',
'orderable': false,
'data': null,
'defaultContent': ''
},
{
'orderable': false,
'className': 'select-checkbox',
'targets': 0
},
{ 'data': 'category' },
{ 'data': 'test' },
{ 'data': 'automatable' },
{ 'data': 'priority' }
],
'select': {
'style': 'multi',
'selector': 'td:not(:first-child)'
},
'order': [[1, 'asc']]
} );

// Add event listener for opening and closing details
$('#example tbody').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );

  if ( row.child.isShown() ) {
     // This row is already open - close it
     row.child.hide();
     tr.removeClass('shown');
  }
  else {
     // Open this row
     row.child( format(row.data()) ).show();
     tr.addClass('shown');
  }

} );
} );

Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 82534


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>