stateSave not saving paging position

stateSave not saving paging position

classic12classic12 Posts: 228Questions: 60Answers: 4
edited December 2017 in DataTables

Hi guys,

I have the following

 $("#dtCustomers").dataTable().fnDestroy(); 
        $('#dtCustomers').empty();
        tableCustomers = $('#dtCustomers').DataTable( {

        ajax: {
        url : "http://www.xxx.com/xxx.php",
        type: 'POST'
        
        },
        //serverSide : true,
        customerData : data,
        scrollY: "300px",
        scrollCollapse: true,
        lengthChange: false,
        pagingType: "simple",
        stateSave: true,
        stateSaveCallback: function(settings,data) {
          localStorage.setItem( 'DataTables_' + settings.sInstance, JSON.stringify(data) )
        },
        stateLoadCallback: function(settings) {
          return JSON.parse( localStorage.getItem( 'DataTables_' + settings.sInstance ) )
        },
        paging: true,
        info: false,
        select: true,
        ordering: true,
        order: [[0, 'desc']],
        dom: "Bfrtip",
        autoWidth : true,
        responsive: true,
        select: true,

On the customer table.
I page down and expand a row
In another instance I update some data in the row
I then hit refresh button which reloads the ajax
The datatable is set to the first record.
If I page down I see the row in its open state with the new data.

So the paging position doesn't seem to be working.

I see in the Local Storage the following

DataTables_dtCustomers

{"time":1513858618095,"start":0,"length":10,"order":[[0,"desc"]],"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true},"columns":[{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}},{"visible":true,"search":{"search":"","smart":true,"regex":false,"caseInsensitive":true}}]}

Am I missing an option or something here ?

Cheers

Steve Warby

Replies

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934
    edited December 2017

    In another instance I update some data in the row

    Is the update in the other instance reverting back to the first page?

    Maybe describe or show (test case maybe) more info about what exactly you are doing in the other instance.

    Kevin

  • classic12classic12 Posts: 228Questions: 60Answers: 4
    edited December 2017

    Sorry the other instance I meant just change the data in the database.

    Can't show a link because of private data

    Cheers

    Steve Warby

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934
    edited December 2017

    change the data in the database

    Does stateSave work if you reload the page without updating the data?

    When you go to page 2, for example, does the start parameter change?

    But then when you reload the page its back at 0?

    The other "instance" does not display the Datatable?

    Kevin

This discussion has been closed.