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

Bug: rows selected lags behind #176

Closed
Tauvic opened this issue Dec 30, 2022 · 2 comments
Closed

Bug: rows selected lags behind #176

Tauvic opened this issue Dec 30, 2022 · 2 comments

Comments

@Tauvic
Copy link

Tauvic commented Dec 30, 2022

Im working on an multi page application with tabs. I want to select multiple rows and get a list of the selected rows. When the users returns to the table I want to show the selected rows using pre_selected_rows.

But when get selected_rows it looks like the selection lags behind.
Looks to me for every selection i make table send two events, the original/old situation and the new situation.
Also it looks like the table keeps updating and looping sometimes.

Is this a bug? What is the correct way to do this? Has it to do with other incluences of multipage and tabs?
Im new to streamlit so I try now to test the most simple setup with a single page.

gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_default_column(hide=True)
gb.configure_column("name",hide=False,width=300,tooltipField="name",
headerCheckboxSelection=True
)
gb.configure_column("branch",hide=False,width=150)
gb.configure_column("startDate",hide=False,width=90,type=["customDateTimeFormat"])
gb.configure_column("endDate",hide=False,width=90,type=["customDateTimeFormat"])
gb.configure_column("roles",hide=False,width=300,tooltipField="roles")
gb.configure_pagination(enabled=True,paginationPageSize=10,paginationAutoPageSize=False)
gb.configure_selection(use_checkbox=True,
selection_mode='multiple',
pre_selected_rows=selected_rows
)
gb.configure_grid_options(tooltipShowDelay=500)

table = AgGrid(df,
gridOptions=gb.build(),
enable_enterprise_modules=False,
update_mode=GridUpdateMode.SELECTION_CHANGED
)

selected_rows = [item['_selectedRowNodeInfo']['nodeRowIndex'] for item in table.selected_rows]
st.session_state[selected_name] = selected_rows

@bradley-hf
Copy link

bradley-hf commented Jan 5, 2023

I'm seeing the same problem, but I'm using the GridUpdateMode.VALUE_CHANGED. The grid is always one event behind and fires multiple events

@Tauvic
Copy link
Author

Tauvic commented Jan 6, 2023

I now have added a button. When clicked i determine the selected rows and store in session state. This is a workaround for the somethwat strange behaviour. Now i can save selected rows and also show them when i switch between pages in a multipage App.
I see new errors in the browser log:
​ AG Grid: do not use api for selection, call node.setSelected(value) instead
t.selectIndex @ main.dc43edd4.js:2
​ AG Grid: suppressEvents is no longer supported, stop listening for the event if you no longer want it

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

3 participants