DataTables logo DataTables

Can't display a row after fnAddDataAndDisplay
  • I have a table that retrieves a Json array via Ajax. It allows editing and adding records via dialog edit forms. After an edit, I use API plugin code like this:

    oTable.fnDisplayRow(oTable.fnGetNodes(index));
    

    (I've retrieved the index by stepping through fnGetData to find the key.) This works fine.

    However, when I *add* a data row using code like this:

    oTable.fnAddDataAndDisplay(row);   // from the plugin
    

    ..the row doesn't appear.

    I've verified that the index is set correctly and the row exists. And I can filter for it with sSearch or fnFilter, or manually page through to it.

    I believe this is because the nTr isn't going to exist on a row that's never been displayed -- so since oTable.fnSettings().aoData[index].nTr is null, fnDisplayRow(fnDisplayRow(oTable.fnSettings().aoData[index].nTr) is going to fail. The line in the plugin:

    var nAdded = oSettings.aoData[ iAdded ].nTr;
    

    is also producing a null. iAdded is correctly calculated.

    Any idea what's wrong with my new table row? Stepping through code now but if you happen to have seen this before...

    Thanks!

    g.
  • Still fussing with this -- FWIW, it seems that it's unrelated to the fact of having just added a row. Only the first 29 rows produce non-null nTr results.
  • Simple enough solution, I just added a

    oTable.fnPageChange( 'last' );
    

    before the row navigation. But I'd love to know what I was doing wrong!
This discussion has been closed.
All Discussions