Show / hide columns dynamically - Saving settings

Show / hide columns dynamically - Saving settings

helpdeskhelpdesk Posts: 20Questions: 3Answers: 0

Hi All,
is there a chance to save status of hidden columns so after page reload they will be still hidden?

https://datatables.net/examples/api/show_hide.html

Thanks,
Jakub

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,753Questions: 1Answers: 10,509 Site admin
    Answer ✓

    Yes - simply use the stateSave option.

    Allan

  • helpdeskhelpdesk Posts: 20Questions: 3Answers: 0
    edited October 2015

    Thank you,
    is there a chance to flag links somehow to show which columns are hidden, it would be very useful once web page is being reloaded? I can achieve this by saving status to the DB, just was wondering that is there already something on place that will simplify it :)

    And the second, I'm using columns search option as well, and once table / web page is being refreshed filters are saved but they don't appear in the search boxes so can be confusing to find out which filter was applied, and ideas how to input original filter there or just don't save state of these?

    Thanks,
    J

  • allanallan Posts: 63,753Questions: 1Answers: 10,509 Site admin

    I would suggest simply using Buttons. It has lots of column visibility control options.

    If you don't want to use Buttons, then yes, you would just need to use columns().visible() to check each column an update the link accordingly.

    Allan

  • helpdeskhelpdesk Posts: 20Questions: 3Answers: 0

    Thanks,
    what about applied columns filters?

    Jakub

  • allanallan Posts: 63,753Questions: 1Answers: 10,509 Site admin

    DataTables knows nothing about the inputs for the column filters, so you would need to apply the saved values when the state is loaded to your input elements. You can get the loaded state using state.loaded().

    Allan

This discussion has been closed.