Hi, I’m back with another Ag Grid question I’m trying to make a popup appear when I click a row, like from the examples: Dash
But my grids are contained in their own tab. My code is here: xenosaga/app.py at ag-grid · perfectly-preserved-pie/xenosaga · GitHub
I’m having issues with the callback, because my grid ID is contained in its own div, which is inside its own tab… if that makes sense. I think the fact that my grid ID is “nested” is making this difficult for me.
So what I’ve tried is this:
@app.callback(
Output("modal", "is_open"),
Output("modal-content", "children"),
Input("ep1_grid", "selectedRows"),
Input("close", "n_clicks"),
)
def open_modal(selection, _):
if ctx.triggered_id == "close":
return False, dash.no_update
if selection:
return True, "You selected " + ", ".join(
[
"{} (model {} and price {})".format(
s["make"],
s["model"],
s["price"],
)
for s in selection
]
)
return dash.no_update, dash.no_update
I’m simply replacing the Input ID with the grid’s ID. But in the console, I’m getting
ReferenceError: A nonexistent object was used in an `Input` of a Dash callback. The id of this object is `ep1_grid` and the property is `selectedRows`. The string ids in the current layout are: [tabs, tab-content, modal, modal-content, close]
So I tried doing something else:
@app.callback(
Output("modal", "is_open"),
Output("modal-content", "children"),
Input("tabs", "selectedRows"),
Input("close", "n_clicks"),
Input("ep1_grid", "selectedRows")
)
def open_modal(tab_selection, _, grid_selection):
if ctx.triggered_id == "close":
return False, dash.no_update
if grid_selection:
return True, "You selected " + ", ".join(
[
"{} (HP {} and EXP {})".format(
s["HP"],
s["EXP"],
)
for s in grid_selection
]
)
elif tab_selection:
return True, "You selected a row from a different tab."
return dash.no_update, dash.no_update
But I’m still getting the same error, and a new one:
Object { message: "Invalid prop for this component", html: 'Property "selectedRows" was used with component ID:\n "tabs"\nin one of the Input items of a callback.\nThis ID is assigned to a dash_core_components.Tabs component\nin the layout, which does not support this property.\nThis ID was used in the callback(s) for Output(s):\n modal.is_open, modal-content.children' }
How can I reference the ep1_grid
ID from the callback? How do I expose it, if it’s nested?