Skip state save in particular cases

Skip state save in particular cases

xtech_devxtech_dev Posts: 25Questions: 11Answers: 0
edited July 2018 in Free community support

Hello,

I have read documentation about stateSave callback's. Is there any way to cancel state saving i particular cases.

I mean something like:

var allowToSaveState = false;
var dt = $('#example').dataTable( {
  "stateSave": true,
  "stateSaveParams": function (settings, data) {
     return allowToSaveState;
  }
});

dt.state.save() // save should be skipped
allowToSaveState = true;

dt.state.save() // save should be preformed

How to make it work?
I'm using DataTables 1.10.18

It Man

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    You need to delete the items you don't want from the data object - e.g.:

    delete data.columns;
    

    Allan

  • xtech_devxtech_dev Posts: 25Questions: 11Answers: 0
    edited July 2018

    Will it stop saving (storage not touched) or only prevent from saving particular state components?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    or only prevent from saving particular state components?

    This.

    There isn't currently a way to stop it saving if state saving is enabled (also, even if there was, the last state that was saved would still be present).

    Allan

This discussion has been closed.