how to fix the problem related to the order of list when using the stateSave option?

how to fix the problem related to the order of list when using the stateSave option?

Daniel_YeoDaniel_Yeo Posts: 1Questions: 1Answers: 0
edited June 2021 in DataTables 1.10

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:

Description of problem: I want to keep the state information for my dataTables so I used the option of stateSave for maintaining the state value(ex: the value of lengthMenu) but when adopting this option, the order of list is changed unintentionally.
the code lines which I written are two lines as the below.

            stateSave: true,
            stateDuration: 0,

If I remove the upper lines(stateSave: true, stateDuration: 0), then the order is no problem. so how can I solve this problem?

The total code is as the follow.

        keywordTable = $('#keyword-table').DataTable({
            "paging": true,
            "lengthMenu": [[20, 50, 100, -1], [20, 50, 100, "Total"]],
            stateSave: true,
            stateDuration: 0,
            "info": true,
            "order": [],
            columnDefs: [
                {
                    "targets": [2],
                    "visible": false,
                    "searchable": false
                },
                { type: 'any-number', targets: 4 },
                { type: 'any-number', targets: 5 },
            ],
            "columns": [
                { "orderDataType": "dom-checkbox" },
                null,
                null,
                null,
                null,
                null,
                null,
                { "orderDataType": "dom-text-numeric", "type": "numeric" },
                { "orderDataType": "dom-text-numeric", "type": "numeric" },
                { "orderDataType": "dom-text-numeric", "type": "numeric" },
                { "orderDataType": "dom-text-numeric", "type": "numeric" },
                null,
                null,
                null,
                null,
                null,
                null,
                null
            ],
        });

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.