[Python] Shiny for Python has no acces to datagrid. dataframe

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    @reactive.Effect
    @reactive.event(input.personnel_grid_selected_rows)
    def show_person_modal():
    selected_rows = input.personnel_grid_selected_rows()

    if selected_rows:
    print(f"Selected Rows: {input.personnel_grid_selected.get()}")

    # Get the current data from the selected rows
    df = pd.DataFrame(input.personnel_grid_selected)
    print(df)
    if not df.empty:
    # Get the first selected row index
    row_index = selected_rows[0]
    row_data = df.iloc[row_index]

    # Build modal content
    content = ui.div(
    ui.h4(f"{row_data['First Name']} {row_data['Last Name']}"),
    ui.p(f"Email: {row_data['Email']}"),
    ui.p(f"Phone: {row_data['Phone']}")
    )

    # Show modal
    ui.modal_show(
    ui.modal(
    content,
    title="Person Details",
    easy_close=True,
    size="s"
    )
    )


    The key change is using input.personnel_grid_data() which should give us access to the DataGrid's data. This should be the correct way to access the data from a Shiny DataGrid component. But it doesn't work it even exit the methode. Some idea's why?

    Continue reading...

Compartilhe esta Página