How to get dataTable object from code?
How to get dataTable object from code?
Hey everyone, I hope I have a pretty easy question here. I am building a site where i use dataTable. When the page first loads i create a table like
[code]
var oTable = $('.class_path', pane).dataTable({
"sDom": 'Rt',
"bJQueryUI": true,
"sScrollY": "300px",
"bPaginate": false,
});
[/code]
Then later i rip out part of the page that contains the table using .detach and place it somewhere else. This is where the problem lies. When the page gets set the headers of the dataTables are out of line. From there i thought i would be able to call fnAdjustColumnSizing() and fnDraw() to fix the issue. The issue when this is formed it creates one table for the header and one for the scroll body. I am not sure which one to use as the selector (if either).
[code]
var oTable = $('.class_path', pane).dataTable({
"sDom": 'Rt',
"bJQueryUI": true,
"sScrollY": "300px",
"bPaginate": false,
});
[/code]
Then later i rip out part of the page that contains the table using .detach and place it somewhere else. This is where the problem lies. When the page gets set the headers of the dataTables are out of line. From there i thought i would be able to call fnAdjustColumnSizing() and fnDraw() to fix the issue. The issue when this is formed it creates one table for the header and one for the scroll body. I am not sure which one to use as the selector (if either).
This discussion has been closed.
Replies
[code]
var table = $.fn.dataTable.fnTables(true);
if ( table.length > 0 ) {
$(table).dataTable().fnAdjustColumnSizing();
}
[/code]
(note that only works with 1 table, you might need to loop over the table array if you have more than one?).
Allan
Allan
[code]
var table = $.fn.dataTable.fnTables(true);
console.log(table);
[/code]
on both the child and parent window about 5 seconds after loading the child window and it gives back that there are 3 tables on the parent window (which i started off with 2 tables. So there should only be 1 now) and 0 tables on the child window. This is just a confusing issue and I might have to try a different way.
Thanks Allan!