cannot set pageLength when stateSave is set

cannot set pageLength when stateSave is set

hschmitzhschmitz Posts: 4Questions: 1Answers: 0
edited April 2015 in Free community support

I've added stateSave: true as an option for my dataTable. After adding it, my table will save sort and search information. I'm trying to test if it will also save pagination information but I'm unable to set a pageLength. If I comment out the stateSave key, I can set a pageLength without a problem. Here is a snippet from my code:

var table_rows_per_page = 20;

table_instance = table_selector.DataTable({
            "dom": '<"table-wrapper"ftp>',
            "oLanguage": { "sSearch": "", "sSearchPlaceholder": "Search" },
            stateSave: true,
            "lengthChange": false,
            "pageLength": table_rows_per_page,
            "columns": colArray,
            paging: true
        });

Am I missing something or is this possibly a bug? I don't think its a bug because you should be able to store pagination information according to the documentation. If you can store pagination information, you should be able to set the length.

I really appreciate any help!

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    You can set it, but the state saved value is always going to replace it if there is a saved state! Try opening your page in an incognito window - you'll get the default values there since there is no saved state.

    Allan

  • hschmitzhschmitz Posts: 4Questions: 1Answers: 0

    HI Allan,

    Thank you so much! You were right. It also worked in my browser once I cleared my browsing history.

    Its interesting to me that when I comment out the saved state, I was able to change the pagination but when I reinstated it, it went back to its previous saved state (didn't reflect my changed pageLength). I guess it doesn't create a new saved state unless you have a new session.

    Thanks for your time. Have a great weekend.

This discussion has been closed.