I am using jQuery DataTables 1.10 plugin. In the earlier version, (1.9.4 plugin) I was able to get data from table like this:
var iPos = oTable.fnGetPosition( this );
var aData = oTable.fnGetData( iPos );
Now, using the same code, I am getting the error
TypeError: aData is null
How can I use the new functionallity? I tried using oTable.row(iPos).data()
but didn't worked for me
You're trying to access the 1.10 API with the older API methods. fnGetData has been deprecated, as you're seeing. For starters, the Hungarian Notation (mData, fnRedraw) is gone.....it's about time!
The new method is pretty straightforward:
Example to get data from a clicked cell:
var table = $('#example').DataTable();
$('#example tbody').on( 'click', 'td', function () {
var cellData = table.cell( this ).data();
} );
Example to get data from a clicked row:
var table = $('#example').DataTable();
$('#example tbody').on( 'click', 'tr', function () {
var rowData = table.row( this ).data();
} );
Here's the API reference for other questions. You might also benefit from the API conversion guide, where you can look up old functions and see their new equivalents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With