Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column filter when savedstate is activated #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

etiennepouliot
Copy link

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
Copy link
Author

Failed flake8 are fixed in #73

@olevchyk
Copy link

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 ?

@drowe-official
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants