Using fnDeleteRow removes wrong row after 1 or more rows are deleted.

Using fnDeleteRow removes wrong row after 1 or more rows are deleted.

ch3fch3f Posts: 3Questions: 0Answers: 0
edited March 2013 in General
Version: 1.8.2

I am using datatables and allowing the user to remove row dynamically. However, I have ran into the issue that if you delete from the top down, row 0 being the first row index. The wrong row will be deleted anytime you try to delete a row after that, assuming you dont refresh the page.

This is how i am using it:
[code]
if(msg == "done"){
var oTable = $j('#example').dataTable();
oTable.fnDeleteRow(row, null, true);

}
[/code]

Am i not using this correctly or maybe there is a work around. I cannot redraw the table because there could be a running process in the table at the same time the row is deleted.

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    The code looks okay to me, but it depends upon what `row` is. Please link to a test case so we can see the problem and offer some help.

    Allan
  • ch3fch3f Posts: 3Questions: 0Answers: 0
    Currently I am passing "row" using oObj.iDataRow, defined something like this:
    [code]
    onclick="doingIt(oObj.iDataRow)"
    [/code]

    And this is working up to the point where the row(s) are deleted.

    Should I be using something like fnGetPosition() to find the row? If so,
    [code]
    aPos = oTable.fnGetPosition( this )[0];
    console.log("outside "+ aPos);
    [/code]

    gives me this error:
    [code]
    Uncaught TypeError: Cannot call method 'toUpperCase' of undefined
    [/code]
This discussion has been closed.