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

Getting AggGrid's state #14

Closed
adamlansky opened this issue Mar 4, 2021 · 5 comments
Closed

Getting AggGrid's state #14

adamlansky opened this issue Mar 4, 2021 · 5 comments

Comments

@adamlansky
Copy link

Hey @PablocFonseca, thank you for such an amazing job on integrating AggGrid in Streamlit, I highly appreciate the efforts and happy to contribute if there are any known issues that need help from python side of things.

One task I am having hard time to wrap my head around is getting AggGrid state after a user interacts with it.

I.e., I have a multi-select to keep grouping consistent between page reloads or new data push.

# let user pick cols from dataframe she want to group by
if st.sidebar.checkbox("Enable default grouping"):
    default_group_col = st.sidebar.selectbox("Default group by: ", cols, 1)

# if any of columns are selected, apply it to aggrid and persist on page reload,
# as default_group_col state is persisted under the hood by streamlit
try:
    gb.configure_column(default_group_col, rowGroup=True)
except:
    pass

Now say a user groups by an additional column using AggGrid groupby feature, collapses some of the resulting groups and keeps the others expanded. I would assume AggGrid itself stores this state somewhere in client side JS. Is there a potential way to get stat state back to python in order to save it somewhere in a dict and persist between page reloads when AggGrid component is being redrawn or populated with new data?

Thanks!

@ragrawal
Copy link

I have a similar question. Is there a way to get the modified data back in python

@PablocFonseca
Copy link
Owner

PablocFonseca commented Aug 2, 2021

check the example folder (e.g. two_grids.py)
to get modified data, you would use something like:

grid_return = AgGrid(df, key='grid1', editable=True)
df = grid_return['data']
st.write(df)

@PablocFonseca
Copy link
Owner

The feature to save grid's current state is not implemented yet.
I just saw this post: https://blog.ag-grid.com/persisting-ag-grid-state-with-react-redux/#managing-state-in-ag-grid

So, it can be done. Unfortunately, I'm lacking the time to dig into this..

@gandhis1
Copy link

This issue was closed as completed, is it completed? I think leaving this one open would make sense until it is actually implemented. I would very much find this feature useful.

@estaar
Copy link

estaar commented Jun 21, 2022

Hi. Was this feature implemented. Would you suggest what to edit in J's code to make this work?

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

No branches or pull requests

5 participants