i need execute function after draw table
i need execute function after draw table
drodriguez
Posts: 8Questions: 2Answers: 0
Hi! Thanks in advance for the help! I am needing to execute my own function once the table is finished drawing
I add a section of code that was used to load the data from the table (this method because the rows and columns are dynamic that when arriving at the table I do not know how many rows or columns arrive)
$('#res_x_emp').DataTable( {
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.21/i18n/Spanish.json"
}, "ordering": false,
data: data.data,
columns: columns
});
Answers
Are you looking for this function to run once after initialization (use
initComplete
) or each time the table draws (use eitherdrawCallback
ordraw
)?Kevin
I really need it once the table is finished drawing, the rows and columns are loaded, as you can see with the options you gave me, it launches the alert but the rows or columns are not drawn yet
Does the table load columns and row data without
initComplete
?Can you provide a link to your page or a test case replicating the issue so we can see what is happening and help debug?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Thanks for the code snippet but the question still remains - is the table columns and rows populated properly?
You showed a screenshot with an alert. What exactly did you use to generate the alert?
Either please provide more details of what is happening and what you have you have done to troubleshoot or a link to a test case showing the issue. Without that we won't have the information needed to help debug.
Kevin
Yes, the table is filled correctly, at the moment the alert is launched I need to invoke another function but the grid must already be loaded for that
Use
initComplete
to run a function after all the data has been loaded.Kevin