I’m trying to set the options of the Select Editor (dropdown) each time i access a cell dropdown editor.
The rowMenu seemed good to start from, but a rowMenu does not display the value of the cell.
import random, json
import dash
from dash import Dash, html, dcc, Input, Output, State, Patch, ctx, MATCH, ALL
import dash_ag_grid as dag
app = Dash(__name__)
columnDefs = [
{"field": "A"},
{
"field": "dynamic_select",
"editable": True,
"cellEditor": "agSelectCellEditor",
"cellEditorParams": {
"values": [f'set@starup{i}' for i in range(4)],
},
},
]
rowData = [
{"A": "a1", "dynamic_select": "--"},
{"A": "a2", "dynamic_select": "--"},
{"A": "a3", "dynamic_select": "--"},
]
app.layout = html.Div(
[
dag.AgGrid(
id="table",
columnDefs=columnDefs,
rowData=rowData,
),
html.Div(id="dynamic_dropdown_option_output"),
],
style={"margin": 20},
)
@app.callback(
Output("dynamic_dropdown_option_output", "children"),
Input("table", "cellDoubleClicked"),
prevent_initial_call=True,
)
def set_dynamic_dropdown_editor_options(cell_data):
# simulate bogus ever-changing dropdown options
# set options to the Select Editor Dropdown in somne way
return [f' server_query_{random.randint(0,9)}' for i in range(random.randint(1,7))]
if __name__ == "__main__":
app.run(debug=False)
So I started with a more generic MRE.
Does anyone know how to achieve this?
Thx