Lara
Lara

Reputation: 3021

Unable to get property 'aDataSort' of undefined or null reference on calling .datatable

I have create and populated Jquery Datatable dynamically using Ajax. After Datatable got created, I am trying to access its row values but getting error like Unable to get property 'aDataSort' of undefined or null reference. Here is the code adding which the above error is coming at loading time of the page, if I am not adding the page is rendering fine.

var tbtable = $('#SettingsDatatable').DataTable();
var dataa = tbtable.row($(this).closest("tr")).data();

Please help.

Upvotes: 1

Views: 752

Answers (1)

Chris H.
Chris H.

Reputation: 2594

If you want to get the data for all rows (which it sounds like you do), you just need to change

var dataa = tbtable.row($(this).closest("tr")).data();

to

var dataa = tbtable.rows().data();

Your previous version is what you would use if you wanted to get a single row's data, but if that's the case, you have to actually call that from something that can identify what this is, where this refers to something within the <tr> element of the row whose data you want to retrieve.

Upvotes: 1

Related Questions