Passing DataTable object to initComplete callback
Passing DataTable object to initComplete callback
dabee
Posts: 19Questions: 3Answers: 0
Hi @alan
Thank you for your great work!
Can't figure out
Let's say I have this code:
function afterTableInitialization(table) {
table.columns().every( function () {
// any code ...
});
}
table = $('table').DataTable({
"initComplete": afterTableInitialization (table)
});
And I certainly get Uncaught ReferenceError: table is not defined
I do this with external callback cause of using ajax to load table contants and then initiating DataTables itself
So the question is - how do I pass initialized DataTable object to my callback so I can operate it via API?
Thanks in advance
This discussion has been closed.
Replies
Well I guess I've just figured it out myself.
So the code should look like this:
So the main changes is that I pass settings to my callback (json is optional in this case) and then get DataTables object out of it with table = settings.oInstance.api();
Hope this will help someone:)