Save State to save only display length

Save State to save only display length

SkeetsSkeets Posts: 4Questions: 2Answers: 0

I'm looking for a way to use DataTable's (1.10.13) "save state" functionality, but I need it to save only the display length, and not the filter, sorting, or anything else. I found some documentation indicating that I need to use "fnStateLoadParams", but I couldn't figure out how to use it.

I spent a while looking for the correct documentation for my version of DataTables, but no luck so far. Could someone point me in the right direction? (either a link to the correct documentation page or a hint as to what to do here?)

Thanks. :smile:

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Answer ✓

    stateSaveParams might help. It seems kind of the wrong way round, but it enables removing the options you don't want saved.

  • SkeetsSkeets Posts: 4Questions: 2Answers: 0

    Thanks! That was probably the page I was looking for :smile:

    Here is my solution that seems to be working:

        "stateSave": true,
        "stateSaveParams": function (settings, data) {
          data.search.search = "";
    //      data.order = null;      ---> This didn't work, instead of setting sort to default, it clears all sorts.
          data.order = dtSort;  // dtSort contains the default sort
          data.start = 0;
          delete data.columns;
        },
    
    
    
This discussion has been closed.