ColVis with jquery cookie?

ColVis with jquery cookie?

versakversak Posts: 26Questions: 0Answers: 0
edited October 2012 in General
Been trying to set up a cookie for saving and returning the ColVis data. My basic code is (hand typed from intranet):
[code]
var columnDisplayIndex = $.cookie("columnIndexCookie");
$("#datatable).ready(function(){
$("#datatable).dataTable({
......
"aoColumnDefs" : [{
"bVisible" : false, "aTargets" : [columnDisplayIndex]
}]
.......
"fnDrawCallback" :
function(oSettings){
var vCols = new Array();
.each($("#openTable").dataTable().fnSettings().aoColumns, function(c){
if(oSettings.aoColumns[c].bVisible == false){
vCols.push(c);
}
});
$.cookie("columnIndexCookie", vCols, {expires:90})
.....
[/code]

I can return the values (print out in the firebug console logs) when I click the ColVis buttons and I can see the values in the cookie. I can return the values from the var in the cookie (var columnDisplayIndex ) but it doesn't seem to read it on refresh or load when it gets to the aoColumnDefs.

Any ideas what i'm missing here?

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    CoLVis state saving should be handled by DataTables / ColVis automatically. There should be no need to add any additional code other than bStateSave: true .

    Allan
  • versakversak Posts: 26Questions: 0Answers: 0
    bStateSave has never worked for our circumstances. i've gone back to retry it and it never works for me.

    Some of the tables that we have a pretty huge and it was always an issue with the cookie size and our outdated browsers.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    How out dated? Is localStorage an option?
  • versakversak Posts: 26Questions: 0Answers: 0
    localstorage is not an option. most of users are using IE7
This discussion has been closed.