django-ajax-datatable icon indicating copy to clipboard operation
django-ajax-datatable copied to clipboard

Fix column filter when savedstate is activated

Open etiennepouliot opened this issue 3 years ago • 3 comments

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 : image

with this patch : image

etiennepouliot avatar Dec 15 '21 21:12 etiennepouliot

Failed flake8 are fixed in #73

etiennepouliot avatar Dec 15 '21 21:12 etiennepouliot

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 ?

olevchyk avatar Jan 27 '23 09:01 olevchyk

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

drowe-official avatar Jul 20 '23 14:07 drowe-official