-
Notifications
You must be signed in to change notification settings - Fork 207
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
Enable User Column Filters #98
base: dev
Are you sure you want to change the base?
Conversation
@PablocFonseca other than resolving the merge conflicts, is there anything else you would want before merging this PR? |
Hi @kmcentush, |
Hi @laky55555, that's more or less what I did by making these tweaks to the source. You can keep the filters in the streamlit state and apply it whenever the data changes, etc. Here's the branch I was using in my own setup: https://github.com/cuberg-inc/streamlit-aggrid/commits/feat/col_filters |
Hi guys, I really appreciate what you did, @kmcentush. However, I want to know if you managed to set the initial value for the filters. I'm facing a problem where I want to set the filters before Ag-Grid is mounted. I tried setting the "filterModel" attribute in gridOptions, but it didn't work. This is how it looks: |
I recall working around it some way by setting the filters before causing a streamlit refresh immediately after first load. My team and I moved away from AggGrid more than a year ago, so unfortunately the code is buried in our commit history. That being said, if it seems like the filters work after initial mounting/on refresh, I think the brute-force strategy will work (albeit but not elegantly) |
Thanks for answering @kmcentush, for curiosity, you and your team moved from Aggrid to what? |
@devpedrorocha Our Aggrid use cases were replaced with Looker, as we mainly were using Streamlit for BI cases. The few places we still use Streamlit are for the much more dynamic interactions, but we've achieved those with Streamlit's own built in widgets, etc. |
For my specific use case, there is a huge advantage to letting my users ultimately export their current column filters and later re-upload them. This can shortcut a lot of manual filtering if the user does pretty routine analysis.
This pull request exposes the ability to both read/write the column filters through the Ag-Grid enterprise
setFilterModel
andgetFilterModel
functions. On instantiation (or whenever the AgGrid Streamlit componentkey
changes), these column filters can be applied automatically for the user. After the user filters the data, their filters can be accessed through the newcolumn_filters
field in the component value/response.Please let me know if you have any questions. Happy to create a minimal Streamlit example if my use case is not clear.
Edit: I also fixed a bug in the
text_columns
aspect of thecast_to_serializable
function. That is unrelated to the specific use case here, but I did encounter it while making this PR.