fnAddData returns null on empty table

fnAddData returns null on empty table

markdlmarkdl Posts: 2Questions: 0Answers: 0
edited February 2010 in TableTools
Hi,

I'm a newbie on using DataTables. I have this table where you can add and delete the rows. I'm using fnAddData() and fnDeleteRow() to add and delete data. During initialization of table using ajaxsoruce, works fine. Adding new data also works. But when the table is already empty, fnAddData fails with the error "nTrs[iRow] is null".

Does fnAddData() requires a non empty table?

I'm not quite sure if I'm doing the correct way of deleting and adding new data to the table.

Please help. Thanks!

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,498 Site admin
    I just tried a slightly modified version of this example: http://localhost/datatables/dataTables-1.6/examples/api/add_row.html (the modification being to remove the first default row), and it seems to work no problem. Are you sure you are giving fnAddData an array with the correct number of elements? Do you have an example link you can post showing it not working please.

    Allan
  • markdlmarkdl Posts: 2Questions: 0Answers: 0
    yes you're right. =) fnAddData is really working. I'm passing the correct number of elements. Problem is during my usage of fnDeleteRow. I set it up with the 3rd parameter as true (Null the row from the internal aoData object) which really gave a null value to the object. I was expecting that fnDeleteRow would actually remove the whole object but turns out that it only nulls its value. When all the elements are already null, then the error comes out for fnAddData.

    I guess having the 3rd parameter of fnDeleteRow to false would be good for me.

    Thanks!
This discussion has been closed.