I have a multipage app. The app pages are market.py and profile.py. This is how i register those pages:
market.py: dash.register_page(name, path=“mkt-to-mkt”)
profile.py: dash.register_page(name, path=“profile”)
In market.py I have a dash datatable with this layoud and callback (below). As you can see one of the tables columns is Building Name.
dash_table.DataTable(id='table-mkt', row_selectable='single') # allow single selection
# Callback: Generate Table
@callback(
Output("table-mkt", "data"),
Output("table-mkt", "columns"),
Input("submit-mkt", "n_clicks"),
State("tree-select-region-mkt", "value"),
State("tree-select-country-mkt", "value"),
State("tree-select-city-mkt", "value"),
State("tree-select-property-mkt", "value"),
State("tree-select-ownership-mkt", "value"),
State("tree-select-bu-mkt", "value"),
)
def update_table(n_clicks, region, country, city, sel_property, ownership, bu):
# If n_clicks is None, display df with specified columns
if n_clicks is None:
columns = [{'name': 'Lease ID', 'id': 'LeaseID'}, {'name': 'Building Name', 'id': 'Building Name'}]
return mkt_df.to_dict('records'), columns
else:
df_to_use = mkt_df[(mkt_df['Region'].isin(region)) &
(mkt_df['Country'].isin(country)) &
(mkt_df['City'].isin(city)) &
(mkt_df['Building Type'].isin(sel_property)) &
(mkt_df['Ownership Type'].isin(ownership)) &
(mkt_df['Business Unit'].isin(bu))]
# Select columns
columns = [{'name': 'Lease ID', 'id': 'LeaseID'}, {'name': 'Building Name', 'id': 'Building Name'}]
return df_to_use.to_dict('records'), columns
Now in my profile.py page, I have building dropdown:
dmc.Select(
data=[{'label': i, 'value': i} for i in df['Building Name'].unique()],
value=df.iloc[0]['Building Name'],
id="building-id",
)
What i want to achieve is the following. When the user selects a row from dash datatable in market.py page, i want building profile page building dropdown to automatically populate the building name that the user selected in the market.py page. Ideally, i also want that as soon as user makes a row selection in dash datatable in market.py i want to automatically be transfered to building profile page with the dropdown set to building name from selected row.
Any guidance pleas e?