clear (skip) saved state

clear (skip) saved state

dtUserdtUser Posts: 4Questions: 0Answers: 0
edited September 2011 in General
Hello,

There are some cases, depending on the code conditions, when one might need to not load the saved state in a particular step. How can we skip the saved state restoration without setting it off?

Replies

  • dtUserdtUser Posts: 4Questions: 0Answers: 0
    edited September 2011
    I found one way, by altering the jquery.dataTables.js. This way I can skip and clear the saved state when I have a predefined column filter which needs to have priority (in aoSearchCols).

    [code]
    /* start existing code */
    function _fnLoadState ( oSettings, oInit )
    {
    if ( !oSettings.oFeatures.bStateSave )
    {
    return;
    }
    /* end existing code */

    /* start my code */
    for(i in oInit.aoSearchCols){
    if(oInit.aoSearchCols[i])
    return;
    }
    /* end my code */
    .
    .
    .
    [/code]

    Is there any other way?
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    Hi!

    Yup - fnStateLoadCallback is what I think you are looking for - http://datatables.net/ref#fnStateLoadCallback . If you don't want to load state, just have that function return false.

    Allan
This discussion has been closed.