Can't load search state of specific column?
Can't load search state of specific column?
morrty
Posts: 29Questions: 6Answers: 0
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.
This discussion has been closed.
Answers
Figured it out. The following returned the state: