Why no fnGetColumnVis?
Why no fnGetColumnVis?
Hi.
I have a set of toggler buttons at the top of DataTables where user can show / hide various column by clicking on these toggle buttons. I was able to do this very easily thanks to fnSetColumnVis function. I have also noticed that show/hide states for each column is preserved via Cookie so that next time user opens the same page, he/she will see the same set of shown columns.
I can not, however, figure out a way to reset my toggle buttons state based on information stored in the cookie when user first opens the page. I can parse the Json stored in the cookie parameter "abVisCols" to get to this information, but the clearer way to implement this is to call something like "fnGetColumnVis" (and no such function exists) during initialization and reset the toggler.
Does this function not exist because other users are able to accomplish what I am trying to accomplish in a different way? Or should I request that this function to be added?
Thanks!
Soichi
I have a set of toggler buttons at the top of DataTables where user can show / hide various column by clicking on these toggle buttons. I was able to do this very easily thanks to fnSetColumnVis function. I have also noticed that show/hide states for each column is preserved via Cookie so that next time user opens the same page, he/she will see the same set of shown columns.
I can not, however, figure out a way to reset my toggle buttons state based on information stored in the cookie when user first opens the page. I can parse the Json stored in the cookie parameter "abVisCols" to get to this information, but the clearer way to implement this is to call something like "fnGetColumnVis" (and no such function exists) during initialization and reset the toggler.
Does this function not exist because other users are able to accomplish what I am trying to accomplish in a different way? Or should I request that this function to be added?
Thanks!
Soichi
This discussion has been closed.
Replies
It doesn't exist because I never really thought about it before :-). Probably a good one for a plug-in API function... ( http://datatables.net/development/api ). What you can do is loop over aoColumns (in the settings object) and check what bVisible is for each column. From that an array can be created with the current state of visibility.
Regards,
Allan