How do I reference an existing datatable?
How do I reference an existing datatable?
totallyplandom
Posts: 27Questions: 1Answers: 1
Hi All,
I need to be able to reference information from an existing datatable in one of my "static" javascript methods. Meaning, I can't place the method inside the initial jQuery $(). And, if I attempt to make another "datatable()" call, it simply tries to redraw it (which, of course, is bad)
That said, is there a universal (or just generally acceptable) mechanism by which to reference an existing datatable?
FYI, my ultimate goal is to be able to remove checked rows after an independent ajax "delete" call to the back end.
Best.
I need to be able to reference information from an existing datatable in one of my "static" javascript methods. Meaning, I can't place the method inside the initial jQuery $(). And, if I attempt to make another "datatable()" call, it simply tries to redraw it (which, of course, is bad)
That said, is there a universal (or just generally acceptable) mechanism by which to reference an existing datatable?
FYI, my ultimate goal is to be able to remove checked rows after an independent ajax "delete" call to the back end.
Best.
This discussion has been closed.
Replies
[code]
$('#example').dataTable();
[/code]
if your version does, you can include bRetrieve : true to simply retrieve the table without processing the initalization (if the table exists it won't reinitialize.. if it doesn't, it will process the init for you)
[code]
$('#example').dataTable({
"bRetrieve": true
});
[/code]
You could also go the route of having a global variable oTable declared outside the jQuery call
[code]
var oTable;
$(document).ready( {
oTable = $('#example').dataTable({
// initializers here
});
} );
[/code]
[code]
$('#first_table #second_table #third_table').dataTable();
[/code]
[code]
$('#first_table').dataTable();
$('#second_table').dataTable();
[/code]
etc - or you can use iApiIndex: http://datatables.net/development/ (there isn't a huge amount of documentation for it, but you just change it to the index of the table you want in the object).
Allan