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

StopIteration due to columnDefs #230

Open
sfc-gh-pkommini opened this issue Aug 15, 2023 · 1 comment
Open

StopIteration due to columnDefs #230

sfc-gh-pkommini opened this issue Aug 15, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@sfc-gh-pkommini
Copy link
Contributor

sfc-gh-pkommini commented Aug 15, 2023

Error Trace:

File "/opt/homebrew/Caskroom/miniconda/base/envs/snowpark/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
File "/Users/<redacted>/sfc-workspace/streamlit-uar/uar/1_Manager_App.py", line 41, in <module>
    options.configure_selection(
File "/opt/homebrew/Caskroom/miniconda/base/envs/snowpark/lib/python3.10/site-packages/st_aggrid/grid_options_builder.py", line 258, in configure_selection
    first_key = next(iter(self.__grid_options["columnDefs"].keys()))

Hi Team,

I'm using the following code but I constantly get the above error. Has anyone faced this before or know what I'm doing wrong?

df_filtered = df_reviews.filter(
    items=['col1', 'col2', 'col3', 'col4', 'col5']
)
options = GridOptionsBuilder.from_dataframe(
    df_filtered,
    enableRowGroup=True,
    enableValue=True,
    enablePivot=True,
)
options.configure_pagination(
    paginationAutoPageSize=False,
    paginationPageSize=10,
)
options.configure_selection(
    selection_mode='multiple',
    use_checkbox=True,
    header_checkbox=True,
    pre_selected_rows=st.session_state.pre_selected_rows,
)

grid_return = AgGrid(
    df_filtered,
    fit_columns_on_grid_load=True,
    columns_auto_size_mode=ColumnsAutoSizeMode.NO_AUTOSIZE,
    data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
    gridOptions=options.build(),
    theme=AgGridTheme.STREAMLIT,
    key='my_grid',
)
@sfc-gh-pkommini
Copy link
Contributor Author

sfc-gh-pkommini commented Aug 15, 2023

Also found that removing the last argument to configure_selection for picking pre_selected_rows from session_state maybe the culprit here:

This doesn't work.

options.configure_selection(
    selection_mode='multiple',
    use_checkbox=True,
    header_checkbox=True,
    pre_selected_rows=st.session_state.pre_selected_rows,
)

This works without the error.

options.configure_selection(
    selection_mode='multiple',
    use_checkbox=True,
    header_checkbox=True,
)

Workaround that unblocks me.

if not st.session_state.pre_selected_rows:
    options.configure_selection(
        selection_mode='multiple',
        use_checkbox=True,
        header_checkbox=True,
    )
else:
    options.configure_selection(
        selection_mode='multiple',
        use_checkbox=True,
        header_checkbox=True,
        pre_selected_rows=st.session_state.pre_selected_rows,
    )

@PablocFonseca PablocFonseca added the help wanted Extra attention is needed label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants