Can't display a row after fnAddDataAndDisplay

Can't display a row after fnAddDataAndDisplay

grahampcharlesgrahampcharles Posts: 20Questions: 1Answers: 0
edited February 2012 in DataTables 1.9
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:

[code]
oTable.fnDisplayRow(oTable.fnGetNodes(index));
[/code]

(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:

[code]
oTable.fnAddDataAndDisplay(row); // from the plugin
[/code]

..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:

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

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.

Replies

  • grahampcharlesgrahampcharles Posts: 20Questions: 1Answers: 0
    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.
  • grahampcharlesgrahampcharles Posts: 20Questions: 1Answers: 0
    Simple enough solution, I just added a

    [code]
    oTable.fnPageChange( 'last' );
    [/code]

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