Modify aoColumns from callback function
Modify aoColumns from callback function
F30_noris
Posts: 4Questions: 0Answers: 0
Howdy,
our application dynamically modifies the 'bSearchable' attribute of columns and we'd like to restore that state later.
Therfore, I use the 'fnStateSaveParams' callback to store the selection in a cookie.
What leaves me puzzled so far is how to restore it: Both 'fnStateLoadParams ' and 'fnStateLoaded' fire at a stage where the 'aoColumns' array is not yet populated and its future state is stored in 'oInit' instead. 'oSettings.oInit' doesn't contain the same object and therefore doesn't help me either.
What I apprently needed, was a way to access 'aoColumnsInit' or oInit' from the callback function – but this is oviously not possible. So is there another easy way to achieve the desired effect?
Thanks a lot in advance!
our application dynamically modifies the 'bSearchable' attribute of columns and we'd like to restore that state later.
Therfore, I use the 'fnStateSaveParams' callback to store the selection in a cookie.
What leaves me puzzled so far is how to restore it: Both 'fnStateLoadParams ' and 'fnStateLoaded' fire at a stage where the 'aoColumns' array is not yet populated and its future state is stored in 'oInit' instead. 'oSettings.oInit' doesn't contain the same object and therefore doesn't help me either.
What I apprently needed, was a way to access 'aoColumnsInit' or oInit' from the callback function – but this is oviously not possible. So is there another easy way to achieve the desired effect?
Thanks a lot in advance!
This discussion has been closed.
Replies
In fairness I hadn't really expected it to be used quite that way - but it does sound like a sensible use in retrospect!
Allan
Having dived into the DataTables source, the reason for that seems to be that 'oSettings.oInit' starts out as a deep copy of the actual 'oInit' object:
[code]
var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
...
"oInit": oInit,
...
} );
[/code]
But afterwards, a lot of funky stuff happens to 'oInit', which doesn't get applied to 'oSettings.oInit'.
No way to do this? :-(
Could you possibly try this with v1.10 please: https://github.com/DataTables/DataTables/tree/1_10_wip/media/js ? Column detection happens before the state is resolved in v1.10 (which is currently pre-beta).
Allan
Guess I'll wait till 1.10 is stable then.
Allan