Can't load search state of specific column?

Can't load search state of specific column?

morrtymorrty Posts: 29Questions: 6Answers: 0
edited January 2021 in Free community support

I have a simple select input that filters the datatable by searching a specific column.

$("#filter-status").change(function () {
    let search = $(this).find('option:selected').val()
    datatable.column('status:name').search(search).draw();
});

This works great, but on page reload I want the dropdown to be pre-selected with the saved search state. I tried the following which isn't working:

let filterStatusState = datatable.column('status:name').state().search.search;
if (filterStatusState) {
    $("#filter-status").val(state);
}

Am I missing something?

datatable.column('status:name').state().search.search

Returns an empty string, even though the state save is working.

Answers

  • morrtymorrty Posts: 29Questions: 6Answers: 0

    Figured it out. The following returned the state:

    datatable.column('status:name').search()
    
This discussion has been closed.