Datatable Filter after a reload

Datatable Filter after a reload

kagekage Posts: 4Questions: 0Answers: 0

I've tried https://datatables.net/reference/option/stateLoaded

When i set a Filter and reload the page i get the message "Saved filter was: " and nothing more. In this Moment i see all Datarows. But after clicking ok the last Filter is applied. Only one Datarow stays, what is correct but the Combobox with the filter stays empty. I run into this with datatatables 1.10.24 and with 1.11.3 too. How to apply the filter to the combobox too after a relaod?
The Debugger shows correct: "Rows - after search: 1" and no errors. Uploading fails and the site is lokal, so i can't link.

What can i do?

Thanks and best regards.

Replies

  • colincolin Posts: 13,210Questions: 0Answers: 2,257

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kagekage Posts: 4Questions: 0Answers: 0
    edited November 2021

    I hope, i've understand it and it will work :# (sorry my english is not perfect...) live.datatables.net/doselave/3/edit

    Select a Filter in the Position Combobox. The Content is filtered.
    Click on "Run with js" The Content is Filtered but the Position Combobox doesen't show the Filter.

  • kthorngrenkthorngren Posts: 14,519Questions: 25Answers: 3,450

    This thread discusses the same issue. See if it helps.

    Kevin

  • kagekage Posts: 4Questions: 0Answers: 0
    edited November 2021

    The code tags don't work propperly :o , sorry...
    And my last Message is gone?

    I've tried:

                    stateLoadParams: function(settings, data) {
                        alert("now");
                        for (i = 1; i < 6; i++) {
                            var col_search_val = data.columns[i].search.search;
                            if (col_search_val != "") {
                                $("input", $(".datatable.main thead th")[i]).val(col_search_val);
                            }
                        }
                    },
    

    But all rows are visible when the now Message appears. After clicking okay the filtered rows disappear and the comboboxes stay empty :s

    Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • colincolin Posts: 13,210Questions: 0Answers: 2,257
    edited November 2021

    There were a few things wrong with your script.

    1. the example was for input elements, you're using select
    2. the "^" and "$" are being saved, so they need to be trimmed.

    This updated example addresses those two issues,

    Colin

  • kagekage Posts: 4Questions: 0Answers: 0

    Oh my... :o
    It works.

    Many many thanks...

Sign In or Register to comment.