fnOpen and fnAdd in fnRowCallback not working

fnOpen and fnAdd in fnRowCallback not working

JerryKurJerryKur Posts: 5Questions: 0Answers: 0
edited May 2013 in General
Hi,

I am creating a hierarchical table. I am doing this by creating an outer datatable and then on items that have children adding a new datatable that contains the child data. All of this is done with client side data, there is no server side processing.

I am having an issue with fnOpen and fnAdd failing if I add the child table and populate it's data in the fnRowCallback event. But, fnOpen and fnAdd work fine in a button event after the outer datatable is created. The problem appears to be that fnAdd fails because in the code below "this[DataTable.ext.iApiIndex]" is undefined. (DataTable.ext.iApiIndex=0).

[code]
this.fnAddData = function( mData, bRedraw )
{
if ( mData.length === 0 )
{
return [];
}

var aiReturn = [];
var iTest;

/* Find settings from table node */
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );

[/code]

Looking further it looks like a number are undefined on the nRow object such as the parentNode, siblings, etc. I am wondering how much of the datatable is in place when fnRowCallback is called?

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    If `this[ ...iApiIndex ]` is undefined, then there is no table in the current context. I should say that DataTables is not currently designed to have child rows. It is possible, but you'd likely want to attach them in fnDrawCallback, and they can't be part of the parent table (i.e. don't use fnAddData).

    > I am wondering how much of the datatable is in place when fnRowCallback is called?

    None. The table is still to redraw at that point, so the DOM is not up to date.

    Allan
This discussion has been closed.