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

update_cell_selection not working after upgrade to shiny 0.10.0 or more recent #1784

Open
enriquesuso opened this issue Nov 25, 2024 · 0 comments

Comments

@enriquesuso
Copy link

The update_cell_selection applied to a DataGrid was working fine in version 0.9.0. With more recent versions of shiny it is not working any more, doesn't keep the rows selected. I already modified input_cell_selection to cell_selection where needed and checked that rows information is passed correctly in the dictionary. The code is as follows:

sel_rows = reactive.Value()

# Functions to keep rows selected after appying changes to filtered_df dataframe
async def ass_keep_rows_selected(selection):
    print(selection)
    await losses_dg.update_cell_selection(selection)

@reactive.effect
@reactive.event(filtered_df)
def keep_rows_selected():
    cell_selection = {'type': 'row',
                      'rows': sel_rows()}
    # Reapply the selection to losses_dg
    asyncio.create_task(ass_keep_rows_selected(cell_selection))

# Render of table
@output
@render.data_frame
def losses_dg():
    return render.DataGrid(filtered_df(), selection_mode="rows",
                           summary=False, height="300px",
                           width="fit-content")

From the print of "selection" I get for example:
{'type': 'row', 'rows': [2, 3]}

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

No branches or pull requests

1 participant