django-ajax-datatable
django-ajax-datatable copied to clipboard
Fix column filter when savedstate is activated
If we enable state saving (https://datatables.net/examples/basic_init/state_save.html), on a refresh, the column will be filtered but it will not be visible.
IE, without this patch :
with this patch :
Failed flake8 are fixed in #73
I'm also interested in this use-case, is there any alternative way of doing this? like per-populating initialSearchValue for the column filters based on some URI param that holds the state on the backend? Any suggestion or comments regarding the work done in this pr ?
Would also like to see this. A quick glance at the proposed changes- it seems to be the right thing to do. There's a few threads on datatables.net about how to do something like this, and it looks in line with the proposed changes.
See https://datatables.net/forums/discussion/56943/persist-search-value-of-individual-column-with-statesave
tl;dr: Grab the data.columns[i].search.search value and set your custom filter to this value. Rinse and repeat for all custom filters/saved search values.
Note- The linked page's solution uses stateLoadParams and other state callbacks to set the filters. This doesn't seem to work with django-ajax-datatables as the custom filter inputs only exist after these callbacks. I couldn't get them to work, in any case