Call fnGetPosition on datatables.net throws "Unable to call the" toUpperCase "method from undefined"

I am trying to get row position in datatables using the following code

var table = $('#UserInformationTable').dataTable(); var row_id = table.fnGetPosition($('#row_' + id)); table.fnDeleteRow(row_id); 

$('#row_' + id) returns tr.

fnGetPosition does not work. I get this error:

TypeError: cannot call 'toUpperCase' method from undefined

What am I doing wrong?

+8
javascript jquery jquery-datatables
source share
2 answers

table.fnGetPosition(); expects a DOM node, and you pass in a jQuery object. Change it:

table.fnGetPosition($('#row_' + id));

to

table.fnGetPosition($('#row_' + id)[0]);

+17
source share

fnGetPosition expects a node, not a jQuery object. So try:

 var row_id = table.fnGetPosition($('#row_' + id)[0]); 
+6
source share

All Articles