fnDeleteRow problem

fnDeleteRow problem

DFDF Posts: 13Questions: 0Answers: 0
edited September 2010 in General
I am having a problem with fnDeleteRow.

According to the API documentation (http://www.datatables.net/api): the inital input parameter is:

node (TR): the TR element that should be deleted from the table
or
int : Index of the row to delete from the aoData object (use the fnGetPosition() API function to find the index of a row in this array)."

My table looks like this:
[code]



Title
Edit
Delete




Bill Clinton
Edit
Delete


Capital
Edit
Delete



[/code]

It has been initialized like this:
[code]
$('#manage_tbl').dataTable({
"bJQueryUI": true,
"bAutoWidth": false,
"bLengthChange": false,
"bPaginate": true,
"sPaginationType": "full_numbers",
"bScrollCollapse": false,
"iDisplayLength": 20,
"oLanguage": {
"sSearch": "Filter:",
},
"aoColumns":[
{"sWidth": "50%", "bSortable": false},
{"sWidth": "5%", "bSortable": false},
{"sWidth": "5%", "bSortable": false}
]
});
[/code]


I have tried to use fnGetPosition in 2 different ways (the var did is equal to the portion of the row id following the "_"):

[code]
var pos = miTable.fnGetPosition($('#tr__' + did));
[/code]
and
[code]
var pos = miTable.fnGetPosition(document.getElementById('tr__' + did));
[/code]

In either case, I get a jQuery error ("nNode.nodeName is undefined") triggered at at jQuery line 1755:
[code]
if ( nNode.nodeName.toUpperCase() == "TR" )
[/code]

If I try without using fnDeleteRow by passing the node directly using the DOM or jQuery, the row is correctly identified (verified via Firebug) and I don't get an error, but the row does not get deleted:
[code]
miTable.fnDeleteRow(document.getElementById('tr__' + did));
[/code]
or
[code]
miTable.fnDeleteRow($('#tr__' + did));
[/code]

Puzzled. Can anyone help?

TIA

-DF

Replies

  • DFDF Posts: 13Questions: 0Answers: 0
    edited September 2010
    In the words of Mrs. Emily Litella, "never mind" -- I was pointing at the wrong table.

    -DF
  • DFDF Posts: 13Questions: 0Answers: 0
    edited September 2010
    Well, mostly never mind. I was pointing at the wrong table but when I fixed this, it didn't resolve the fnGetPosition error, but I was able to get fnDeleteRow working by passing it the correct DOM TR node as returned by document.getElementById.

    -DF
  • allanallan Posts: 61,439Questions: 1Answers: 10,052 Site admin
    Funny, fnGetPosition should be working :-). One thing to note about your jQuery selectors, you are passing a jQuery object to the DataTables functions there, not a DOM node. To do that, just use the first element of the array:

    [code]
    $('#tr__' + did)[0]
    [/code]
    for example.

    Allan
  • rohitbansalrohitbansal Posts: 2Questions: 0Answers: 0
    Thanks Allan, it was useful......
This discussion has been closed.