colReorder, colVis and reloading settings

colReorder, colVis and reloading settings

0xDEADBEEF0xDEADBEEF Posts: 1Questions: 1Answers: 0

Hi,

We are using colReorder and colVis together and keep having an issue when reloading the settings from localstorage. If a column is moved and another column is hidden, when the page is refreshed and the data is pulled back in from localstorage, the incorrect column is hidden.

It seems the issue occurs here on this line of the _fnLoadState function (where it is not taking into account the reordered columns)

columns[i].bVisible = col.visible;

replacing this line with:

columns[state.ColReorder[i]].bVisible = col.visible;

fixes the issue,

I must be missing something here, as i'm sure many people have used this before in this way and i'd rather not change the source of DataTables.

Any ideas?

Thanks

Answers

  • AshbjornAshbjorn Posts: 55Questions: 2Answers: 16
    edited July 2015

    Hi Deadlock,

    Are you assigning your columns using the data property? I had a similar situation where I was binding my columns using the name property then switch over to data fixed my localStorage woes.

    Before:

    "columns": [
        { "name": "id" },
        { "name": "contract" },
        { "name": "group" },
    ],
    

    After:

    "columns": [
        { "data": "id" },
        { "data": "contract" },
        { "data": "group" },
    ],
    

    Never the less bugs are always possible, but I lack the knowledge to properly assess that.

This discussion has been closed.