Chosing what to save in cookies when bStateSave is true

Chosing what to save in cookies when bStateSave is true

imithyaimithya Posts: 5Questions: 0Answers: 0
edited October 2010 in General
Hi Alan,

I have been using bStateSave on my website having multiple tables on the page. It saves in cookies the value on filtering also along with pagination. But I dont want the value of filtering text to be saved. Is there some way of telling datatables as to values for what parameters should be saved in the cookie?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You can use fnCookieCallback ( http://datatables.net/usage/callbacks#fnCookieCallback ) to modify what is saved by DataTables, delete items or add new ones.

    Allan
  • imithyaimithya Posts: 5Questions: 0Answers: 0
    edited October 2010
    I modified my dataTables initialisation to look like this:

    [code]
    var table = $('.dataTable').dataTable( {
    "bJQueryUI": true,
    "bAutoWidth": false,
    "bProcessing": true,
    "bStateSave": true,
    "jEditable": true,
    "sPaginationType": "full_numbers",
    "aaSorting": [[4,'asc']], /* PulledDateUtc */
    "aoColumnDefs": [
    { "sType": "dwellTime", "aTargets":[6] },
    { "bSearchable": false, "aTargets":[3,5,7,-2,-1] }
    ],
    "fnCookieCallback": function(sName, oData, sExpires, sPath) {
    // Choose what to save in cookie and what not to
    if (sName != 'sFilter')
    return sName + "=" + JSON.stringify(oData) + "; expires=" + sExpires + "; path=" + sPath;
    }
    });
    [/code]

    After making this change, I have been getting the following error on the firebug console:

    sData is not defined
    [Break on this error] Y.location.pathname.split("/");a=a+"_"...{i=eval("("+decodeURIComponent(o[1])+ jquery....min.js (line 106)

    After searching the forum I can make out that something is wrong with the initialisation but Iam not able to figure out what is wrong.
This discussion has been closed.