SearchPanes not loading selections after page refresh

SearchPanes not loading selections after page refresh

georgengeorgen Posts: 3Questions: 1Answers: 0

Hi all,

I am a long-time user of Datatables and have used it on many projects. I must say it's a valuable tool! When I saw that there is a SearchPane extension, I was thrilled since I always had to write custom code to do such things...!

I do face an issue though. I use server-side processing to load data and filter them as well. I am passing the required options to SearchPanes in the AJAX response and the panes render and work as expected.
However, loading the state does not seem to work for SearchPane although it works fine for the rest of the DataTables... The filtered DataTables results are maintained, but the selections on the SearchPanes is not retained. In order to remove a filter, I have to select and deselect it.

Since the project I am currently working on is not public, I don't have a link to share, but I have uploaded the configuration here. I don't get any errors in my console...

This question has an accepted answers - jump to answer


  • colincolin Posts: 15,226Questions: 1Answers: 2,593
    Answer ✓

    Glad you like the extension. Unfortunately, that is a known issue. We're about to release a new extension that and adds more meat to state saving, StateRestore, and that also has the same limitation with server-side SearchPanes. It is something we aim to address, but it's unlikely to be before the end of the year.


  • georgengeorgen Posts: 3Questions: 1Answers: 0

    @colin I assume the searchBuilder has the same issue as well? Haven't tried it yet, but don't want to spend hours implementing it only to find out it doesn't work either.

    And a suggestion on Searchpanes and SearchBuilder: It would be nice if you could actually pass filters and options that are not part of the table itself. For example, I have a table of products that I want to filter using their attributes (colors, types, etc). Those attributes are not part of the table itself and are not part of the AJAX response. I did bypass that by adding dummy columns to the table (setting visible: false and defaultContent = '') but it would be nice to do away with such hacks...

    In any case, I will definitely continue using DataTables! It's by far the best of its kind!

  • colincolin Posts: 15,226Questions: 1Answers: 2,593

    No, SearchBuilder should be fine - this problem only relates to server-side SearchPanes.

    You might be able to use orthogonal data for those attribute issue - see example here.

    And nice, glad you like! :)


  • georgengeorgen Posts: 3Questions: 1Answers: 0

    OK, for anyone else looking for something similar, I figured out a workaround when using server-side processing and state load/save to get the selections back in the SearchPanes:

    $.each(table.state.loaded().searchPanes.selectionList, function(index, list) {
        if (list.rows.length > 0) {
            $.each(list.rows, function(key, value) {
                $('#DataTables_Table_'+index+'_wrapper table').DataTable().row(value.index).select().draw();

    Your data should already be filtered by the server at this point so you only need to select the relevant options again. This method is hacky, but it gets the job done.

Sign In or Register to comment.