fnAddData() when using hidden rows
fnAddData() when using hidden rows
I have a CRUD type interface, that has AJAX called hidden rows using the hidden row API
My question is , because the hidden row API is adding a TH TR on datatable creation, it creates a new column that errors my fnAddData , claiming there is one more column than specified, the extra hidden row column
How do i adjust this to incorporate the hidden row logic i have in the initialization?
[code]dataTable.fnAddData([
response,
$( '#name' ).val(),
$( '#age' ).val(),
'Update | Delete'
]);[/code]
hidden row logic
[code]
/*Insert a 'details' column to the table */
var nCloneTh = document.createElement( 'th' );
var nCloneTd = document.createElement( 'td' );
nCloneTd.innerHTML = '';
nCloneTd.className = "center";
/* removal of this fixes the column headers */
$('#records thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#records tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
[/code]
My question is , because the hidden row API is adding a TH TR on datatable creation, it creates a new column that errors my fnAddData , claiming there is one more column than specified, the extra hidden row column
How do i adjust this to incorporate the hidden row logic i have in the initialization?
[code]dataTable.fnAddData([
response,
$( '#name' ).val(),
$( '#age' ).val(),
'Update | Delete'
]);[/code]
hidden row logic
[code]
/*Insert a 'details' column to the table */
var nCloneTh = document.createElement( 'th' );
var nCloneTd = document.createElement( 'td' );
nCloneTd.innerHTML = '';
nCloneTd.className = "center";
/* removal of this fixes the column headers */
$('#records thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#records tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
[/code]
This discussion has been closed.
Replies
so my fnAddData now reads
[code]
dataTable.fnAddData([
'',
response,
$( '#name' ).val(),
$( '#age' ).val(),
'Update | Delete'
]);
[/code]
My last issue with this is setting the classname in the fnAddData as well, as that className is set in the clone TD hidden row logic
my current code that does not work is this, I know that the problem more than likely is the last statement
[code]
var oSettings = dataTable.fnSettings();
var nTr = oSettings.aoData[ newRow[0] ].nTr;
$('td', nTr)[0].attr( 'class', 'center sorting_1');
[/code]