data.table – Linked @render.data_frame
https://shiny.posit.co/py/components/outputs/datatable/index.html
from shiny import App, render, ui, req import pandas as pd from pydataset import data app_ui = ui.page_fluid( ui.h2("linke two dataGrid"), ui.output_data_frame("table1"), ui.br(), ui.output_data_frame("table2"), ) def server(input, output, session): data1 = data("mtcars").head(5) data2 = data("mtcars") @render.data_frame def table1(): return render.DataGrid(data1, selection_mode='row') @render.data_frame def table2(): selected_row = table1.cell_selection()['rows'] print(f'==1==dictionary>{table1.cell_selection()}') print(f'==2==tuple>{selected_row}') if len(selected_row) <1: print(f'==3==>{"Tuple is empty"}') return None else: selected_row_num = selected_row[0] print(f'==4==>{selected_row_num}') ds = data1.iloc[selected_row_num] df = pd.DataFrame(ds).T return render.DataGrid(df) app = App(app_ui, server)