Set fnDrawCallback after initializing
Set fnDrawCallback after initializing
I'm using the row grouping (http://www.datatables.net/examples/advanced_init/row_grouping.html) so much, that I want to have it as a named function, so I can re-use it on every page with a DataTable. Unfortunately, I can't make it work in such a way that It's still working after a redraw.
Here's my script: http://live.datatables.net/egafik/edit#preview
Based on a comment in another topic (http://datatables.net/forums/discussion/5524/fndrawcallback-listener-adding/p1), I made another script: http://live.datatables.net/iboluz/2/edit#source. That one has the same effect.
Why is fnDrawCallback running only once?
Here's my script: http://live.datatables.net/egafik/edit#preview
Based on a comment in another topic (http://datatables.net/forums/discussion/5524/fndrawcallback-listener-adding/p1), I made another script: http://live.datatables.net/iboluz/2/edit#source. That one has the same effect.
Why is fnDrawCallback running only once?
This discussion has been closed.
Replies
> oTable.fnDrawCallback = ...
that is meaningless to DataTables. What you can do is listen for the 'draw' event:
[code]
$('#example').on('draw', function () { ... } );
[/code]
Worth noting that you are only assigning `undefined` to `oTable.fnDrawCallback` since you are actually executing the function.
Allan
Thanks for your reply!
I tried, but I can't make it happen:
http://live.datatables.net/egafik/4: $('#example').on('draw', GroupByColumn(oTable, 0) );
http://live.datatables.net/egafik/5: $('#example').on('draw', function () { GroupByColumn(oTable, 0); });
My last try was using on('draw'), but the 'init' doesn't work:
$('#example').on('draw', function(e, oSettings) { GroupByColumn(oSettings, 0); } );
$('#example').on('init', function(e, oSettings) { GroupByColumn(oSettings, 0); } );
http://live.datatables.net/egafik/10
What's going wrong?
http://live.datatables.net/ovaguw
I used your example: http://datatables.net/forums/discussion/comment/38750#Comment_38750
If you redraw the table after the event listener has been added it does work: http://live.datatables.net/egafik/12/edit - although there is a script error with an indexing issue somewhere, but the function does at least run now.
Allan