Individual column searching - How to keep selected filter after reload the page?

Individual column searching - How to keep selected filter after reload the page?

mariozupanmariozupan Posts: 4Questions: 1Answers: 0

How to keep selected filter after reload the page, in this example https://datatables.net/examples/api/multi_filter_select.html?

Answers

  • matt_rumsey1212matt_rumsey1212 Posts: 51Questions: 8Answers: 0
    edited December 2015

    have you tried turning the statesave option to true?

    so:

    var table = $("#example").DataTable({
    statesave: true
    })
    
    

    hope that helps/works. I think the standard time is 2 hours but this can also be modified.

  • mariozupanmariozupan Posts: 4Questions: 1Answers: 0

    statesave (or bstatesave) saves the state, but page refresh removes the selected filter value, so I got correct data in datatable, but wrong filter value, ie. empty string.

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    you can allways use my yadcf filter, it support state saving out of the box for all its filter types, see showcase

  • dclar43dclar43 Posts: 47Questions: 13Answers: 2
    edited December 2015

    @daniel_r

    Ugh I can't believed I missed your addon when I was looking for one. I wound up making my own:
    alt

  • mariozupanmariozupan Posts: 4Questions: 1Answers: 0
    edited December 2015

    @daniel_r I tried the yadcf plugin 0.8.8.
    Refresh of the page reset filter value, so the user have to set filter again. "statesave" saves the filtered data, but reset the filter value.

    yadcf 0.8,9 seems to act properly on the site, but I can't see the download link for that version

    thank you on your help

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    yadcf can be downloaded from its github repository

    Here are the link to the raw files

    yadcf latest js

    yadcf latest css

  • allanallan Posts: 62,998Questions: 1Answers: 10,371 Site admin

    DataTables knows nothing about the filter inputs - it knows only that its API has been called and it should filter the table accordingly.

    So if you want to use something like the example on this site with state saving you'd need to use stateLoadParams to fill them back in. Alternatively use YADFC which does this for you.

    Allan

  • mariozupanmariozupan Posts: 4Questions: 1Answers: 0

    @allan Could you please add the code to the example https://datatables.net/examples/api/multi_filter_select.html

  • allanallan Posts: 62,998Questions: 1Answers: 10,371 Site admin

    I will try to make some time in the new year to do so.

    Allan

This discussion has been closed.