How to obtain a reference to an already created DataTable?
How to obtain a reference to an already created DataTable?
Sorry Im really new on this, I create a data table with this code:
$('#gpsDataDetail').dataTable( {
"bProcessing": true,
"sAjaxSource": '/sendLatestGpsData',
"aaSorting": [[1,'asc']]
} );
it works and shows ok the table. But then when I want to use for example the fnReloadAjax function from another function I dont know how to reference the created DataTable. Im doing this. Declaring
oTable = $('#gpsDataDetail').dataTable( {
"bProcessing": true,
"sAjaxSource": '/sendLatestGpsData',
"aaSorting": [[1,'asc']]
} );
with oTable being a global variable. Then I just call the oTable.fnReloadAjax(); and it works but I dont know if it is the best way to do it. Is there a way I can get a reference to the DataTable after it has been created? Thank you.
$('#gpsDataDetail').dataTable( {
"bProcessing": true,
"sAjaxSource": '/sendLatestGpsData',
"aaSorting": [[1,'asc']]
} );
it works and shows ok the table. But then when I want to use for example the fnReloadAjax function from another function I dont know how to reference the created DataTable. Im doing this. Declaring
oTable = $('#gpsDataDetail').dataTable( {
"bProcessing": true,
"sAjaxSource": '/sendLatestGpsData',
"aaSorting": [[1,'asc']]
} );
with oTable being a global variable. Then I just call the oTable.fnReloadAjax(); and it works but I dont know if it is the best way to do it. Is there a way I can get a reference to the DataTable after it has been created? Thank you.
This discussion has been closed.