Handle draw callback triggering twice when having fixedColumns
Handle draw callback triggering twice when having fixedColumns
Hello,
I have draw callback for the datatable having fixedColumns as,
table.on('draw', function(e, settings, json, xhr){
// Logic after table draw
});
With normal datatable (i.e without fixedColumns) this callback trigger only once but this callback triggered twice in case of datatable which has fixedColumns specified.
I think this behavior is due to the fixedColumns as the fixed columns are actually separate table. These fixed tables are then positioned over the original DataTable.
Is there any way we can have this callback to trigger only once even though table has fixedColumns configured? Or are there any parameter with which we can figure out the callback logic is for the main table or for the table which fixed columns?
Thanks,
Amit
Answers
Hi Amit,
Can you give me a link to a page showing the issue please?
Allan
Hi Allan,
I am trying it on my local, below is the code snippet which I am have.
In this case, log is getting printed twice.
Regards,
Amit
I'm only seeing single
draw
events in this example. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.Cheers,
Colin
Hello Colin,
Thanks for sharing the live example. Unfortunately I can not share link to a page.
When I do the column filter/sort it trigger the
draw
only once(as it is in live example) but it trigger thedraw
callback twice while initial loading of datatable.There might be issue with my code. I am debugging my code further and will update here if I figured out the issue.
Thanks for your time and support.
Regards,
Amit
Thats a good hint. Could be something in your
initComplete
or it could have something to do with ajax loaded data. I tried setting up this example:http://live.datatables.net/muwenewa/6/edit
But it seems there is a problem with using the JS BIN ajax examples. I opened this thread to fix the issue.
Kevin
My example with ajax is now working. It calls draw only once. Please post your
initComplete
code to see if anything there might be causing an extra draw.Kevin