ColVis with jquery cookie?
ColVis with jquery cookie?
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?
[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?
This discussion has been closed.
Replies
Allan
Some of the tables that we have a pretty huge and it was always an issue with the cookie size and our outdated browsers.