Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling fnGetPosition on datatables.net throws "Cannot call method 'toUpperCase' of undefined" error

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

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

The $('#row_' + id) is returning a tr.

The fnGetPosition does not work. I am getting this error:

TypeError: Cannot call method 'toUpperCase' of undefined

What am I doing wrong?

like image 717
Nick Avatar asked Jul 11 '13 00:07

Nick


2 Answers

table.fnGetPosition(); expects a DOM node and you're passing a jQuery object. Change it from:

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

to

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

like image 157
Marlon Bernardes Avatar answered Nov 20 '22 17:11

Marlon Bernardes


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

var row_id = table.fnGetPosition($('#row_' + id)[0]);
like image 30
Barmar Avatar answered Nov 20 '22 15:11

Barmar