I am trying to create a table where you can see more details when clicking on a plus image - similarly Example of hidden rows of a DataTables table
Unfortunately, a warning is displayed as a JavaScript warning, and the table title is also inappropriate - as if it had too many or not enough table cells:

I prepared a simple test case that will work instantly when you save it in a file and open it in a browser:
<!DOCTYPE HTML> <html> <head> <link type="text/css" rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css"> <link type="text/css" rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables_themeroller.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script> <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> <script type="text/javascript"> var data = [ {"Total":17,"A":0,"B":0,"Details":{"BSN":"1147387861","ProjectName":"R127","StationName":"D"},"C":0,"D":17,"Test":"GSM_1900_GMSK_TXPOWER_HP_H","Measurement":"MEASUREMENT"}, {"Total":8,"A":0,"B":0,"Details":{"BSN":"1147387861","ProjectName":"R127","StationName":"D"},"C":0,"D":8,"Test":"TX_PWR_64_54","Measurement":"POWER"} ]; $(function() { function fnFormatDetails(oTable, nTr) { var aData = oTable.fnGetData(nTr); var sOut = '<table bgcolor="yellow" cellpadding="8" border="0" style="padding-left:50px;">'; sOut += '<tr><td>BSN:</td><td>' + aData['Details']['BSN'] + '</td></tr>'; sOut += '<tr><td>Station:</td><td>' + aData['Details']['StationName'] + '</td></tr>'; sOut += '<tr><td>Project:</td><td>' + aData['Details']['ProjectName'] + '</td></tr>'; sOut += '</table>'; return sOut; } var fails = $('#fails').dataTable({ bJQueryUI: true, sPaginationType: 'full_numbers', aaData: data, aaSorting: [[2, 'desc']], aoColumns: [ { mDataProp: 'Test', bSearchable: true, bSortable: true }, { mDataProp: 'Measurement', bSearchable: true, bSortable: true }, { mDataProp: 'Total', bSearchable: false, bSortable: true }, { mDataProp: 'A', bSearchable: false, bSortable: true }, { mDataProp: 'B', bSearchable: false, bSortable: true }, { mDataProp: 'C', bSearchable: false, bSortable: true }, { mDataProp: 'D', bSearchable: false, bSortable: true }, ] }); var th = document.createElement('th'); var td = document.createElement('td'); td.innerHTML = '<img src="http://www.datatables.net/release-datatables/examples/examples_support/details_open.png" class="details">'; $('#fails tbody th').each(function() { this.insertBefore(th, this.childNodes[0]); }); $('#fails tbody tr').each(function() { this.insertBefore(td.cloneNode(true), this.childNodes[0]); }); $('#fails tbody').on('click', 'td img.details', function() { var nTr = $(this).parents('tr')[0]; if (fails.fnIsOpen(nTr)) { this.src = 'http://www.datatables.net/release-datatables/examples/examples_support/details_open.png'; fails.fnClose(nTr); } else { this.src = 'http://www.datatables.net/release-datatables/examples/examples_support/details_close.png'; fails.fnOpen(nTr, fnFormatDetails(fails, nTr), 'details'); } }); }); </script> </head> <body> <table id="fails" cellspacing="0" cellpadding="4" width="100%"> <thead> <tr> <th>Test</th> <th>Measurement</th> <th>Total</th> <th>A</th> <th>B</th> <th>C</th> <th>D</th> </tr> </thead> <tbody> </tbody> </table> </body> </html>
Anyone have an idea how to fix this?
I tried adding / removing <th>Details</th> in the body of the HTML, but that didn't help.
I also asked this question on the DataTables forum .
UPDATE:
I received useful comments from the author of DataTables and decided to simply add a plus image to the contents of the first cell in each row - instead of adding a new cell to each row.
Unfortunately, I had a new problem: a plus image is displayed, but there is no single text (test name):

Here is my new code (plus image added by propTest ):
<!DOCTYPE HTML> <html> <head> <link type="text/css" rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css"> <link type="text/css" rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables_themeroller.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script> <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> <script type="text/javascript"> var data = [ {"Total":17,"A":0,"B":0,"Details":{"BSN":"1147387861","ProjectName":"R127","StationName":"D"},"C":0,"D":17,"Test":"GSM_1900_GMSK_TXPOWER_HP_H","Measurement":"MEASUREMENT"}, {"Total":8,"A":0,"B":0,"Details":{"BSN":"1147387861","ProjectName":"R127","StationName":"D"},"C":0,"D":8,"Test":"TX_PWR_64_54","Measurement":"POWER"} ]; function propTest(data, type, val) { if (type === 'set') { console.log(val); // for some reason prints "null" data.name = val; data.display = '<img src="http://www.datatables.net/release-datatables/examples/examples_support/details_open.png" width="20" height="20" class="details"> ' + val; return; } if (type === 'display') { return data.display; } // 'sort', 'type', 'filter' and undefined return data.name; } $(function() { function fnFormatDetails(oTable, nTr) { var aData = oTable.fnGetData(nTr); var sOut = '<table bgcolor="yellow" cellpadding="8" border="0" style="padding-left:50px;">'; sOut += '<tr><td>BSN:</td><td>' + aData['Details']['BSN'] + '</td></tr>'; sOut += '<tr><td>Station:</td><td>' + aData['Details']['StationName'] + '</td></tr>'; sOut += '<tr><td>Project:</td><td>' + aData['Details']['ProjectName'] + '</td></tr>'; sOut += '</table>'; return sOut; } var fails = $('#fails').dataTable({ bJQueryUI: true, sPaginationType: 'full_numbers', aaData: data, aaSorting: [[2, 'desc']], aoColumns: [ { mData: propTest, bSearchable: true, bSortable: true }, { mData: 'Measurement', bSearchable: true, bSortable: true }, { mData: 'Total', bSearchable: false, bSortable: true }, { mData: 'A', bSearchable: false, bSortable: true }, { mData: 'B', bSearchable: false, bSortable: true }, { mData: 'C', bSearchable: false, bSortable: true }, { mData: 'D', bSearchable: false, bSortable: true } ] }); $('#fails tbody').on('click', 'td img.details', function() { var nTr = $(this).parents('tr')[0]; if (fails.fnIsOpen(nTr)) { this.src = 'http://www.datatables.net/release-datatables/examples/examples_support/details_open.png'; fails.fnClose(nTr); } else { this.src = 'http://www.datatables.net/release-datatables/examples/examples_support/details_close.png'; fails.fnOpen(nTr, fnFormatDetails(fails, nTr), 'details'); } }); }); </script> </head> <body> <table id="fails" cellspacing="0" cellpadding="4" width="100%"> <thead> <tr> <th>Test</th> <th>Measurement</th> <th>Total</th> <th>A</th> <th>B</th> <th>C</th> <th>D</th> </tr> </thead> <tbody> </tbody> </table> </body> </html>