Skip to content

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

@enriquesuso

Description

@enriquesuso

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]}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions