Save state to cookie in file protocol

Save state to cookie in file protocol

pedronopedrono Posts: 7Questions: 3Answers: 0

Hello all,

we are creating an HMTL application that uses tables that includes links to PDF files. It has to be used only offline under the File:// protocol (I can't change that!).
When the user gets back from the PDF to the table, sorting and filtering are reset to the initial state.

I know that there is the stateSave option. However, this option uses by default HTML 5 Local storage, which is not available under the File:// protocol.

Is there a way to save the actual datatables state to a cookie using e.g. js-cookie https://github.com/js-cookie/js-cookie or something similar?

I suppose it must be done with the stateSaveCallback option. But I could not make it work.

pedrono

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 49,056Questions: 1Answers: 7,174 Site admin

    stateSaveCallback is indeed how you change how DataTables state saving storage.

    Do cookies work on file://? Its an HTTP property, so I'm not sure they even work there.

    Allan

  • pedronopedrono Posts: 7Questions: 3Answers: 0

    Thanks for the quick reply!

    IE and Firefox can save the cookies under file (chrome not though).
    Can you give a simple example how it basically can be implemented? I can only find Ajax examples.

    I have another replated question.
    Is it possible to use these features with NW.js or Electron 'out of the box'?

    pedrono

  • allanallan Posts: 49,056Questions: 1Answers: 7,174 Site admin
    Answer ✓

    I'd use a library such as Javascript cookie. I can create an example under the quick support options if you like.

    It should be possible to use all of DataTables features in Electron and similar.

    Allan

Sign In or Register to comment.