ordering with statesave enabled

ordering with statesave enabled

ChrisRChrisR Posts: 2Questions: 1Answers: 0
edited November 2018 in Free community support

it appears that order on works only as expected with stateSave = false. Is this as designed?
$('#test').DataTable({ //stateSave: true, "scrollY": '50vh', "scrollCollapse": true, "paging": false, "order": [[0, "desc"]] });

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    edited November 2018 Answer ✓

    it appears that order on works only as expected with stateSave = false.

    Are you saying that you can't order the table with stateSave true or the table order is not set to order": [[0, "desc"]] when the page is reloaded?

    If its the second then you can use stateSaveParams to either remove order from being saved or set it to what you want, for example:

        stateSaveParams: function (settings, data) {
          delete data.order;     //Use this to remove order from being saved
          data.order = [0, "desc"]];  //Or use this to set the order
        }
    

    Kevin

  • ChrisRChrisR Posts: 2Questions: 1Answers: 0

    Kevin - yes, it was the second. Thanks for the solution.

This discussion has been closed.