Hello all,
in my application, I am using an Ajax request which passes me back the HTML fragment of a <TR> to be inserted into the data table.
For doing the insert, I was using Allan Jardine's fnAddTr function.
This post is just to inform other users that I had to adapt Allan's code slightly for my case: I was using named columns (the mData property of each column is set with a fieldname), in this case a hash with the HTML code parts for each cell had to be constructed (otherwise dataTable complained with an error message about "unknown parameter ... ")
in my application, I am using an Ajax request which passes me back the HTML fragment of a <TR> to be inserted into the data table.
For doing the insert, I was using Allan Jardine's fnAddTr function.
This post is just to inform other users that I had to adapt Allan's code slightly for my case: I was using named columns (the mData property of each column is set with a fieldname), in this case a hash with the HTML code parts for each cell had to be constructed (otherwise dataTable complained with an error message about "unknown parameter ... ")
$.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) { ... var aData; // If this table has named columns: if (oSettings.aoColumns[0].mData) { var oCells = {}; for (var i=0;i<nTds.length;i++) { oCells[oSettings.aoColumns[i].mData] = nTds[i].innerHTML; } aData = oCells; } else { // No named columns: Array of content code suffices aData = []; for (var i=0 ; i<nTds.length ; i++ ) { aData.push( nTds[i].innerHTML ); } } ...