import dash_ag_grid as dag
from dash import callback, Input, Output, html, Dash, _dash_renderer
import dash_mantine_components as dmc
import dash_iconify
_dash_renderer._set_react_version('18.2.0')
data = [
{"types": "Social Media", "links": "link"},
{"types": "Development", "links": "link"}
]
columnDefs = [
{
"field": "types",
"headerName": "Link Type",
},
{
"field": "links",
"headerName": "DMC Dropdown Menu",
# "cellRenderer": "DMC_Menu",
"cellStyle": {"overflow": "visible"}
},
{
"field": "links",
"cellRenderer": "DMC_Button",
"cellRendererParams": {
"rightIcon": "ph:eye",
},
}
]
grid = dag.AgGrid(
id="custom-component-btn-grid",
columnDefs=columnDefs,
rowData=data,
columnSize="autoSize",
dashGridOptions={"rowHeight": 48}
)
dropdown = html.Div(
[
dmc.Text(id="menu-text", mb="md"),
dmc.Menu(
[
dmc.MenuTarget(dmc.Button("Click for options!")),
dmc.MenuDropdown(
[
dmc.MenuItem(
"External Link",
href="#/action-2",
target="_blank",
),
]
),
]
),
]
)
app = Dash(__name__)
app_layout = html.Div(
[
html.H1("Dash AG Grid + Dropdown Menu"),
grid,
html.Div(children="", id="div-selected-action"),
dropdown
]
)
# for Dash Mantine 0.14
app.layout = dmc.MantineProvider(
app_layout,
forceColorScheme="light"
)
@callback(
Output("div-selected-action", "children"),
Input("custom-component-btn-grid", "cellRendererData"),
prevent_initial_update=True
)
def cb_menu_action(data):
return f"You selected - {data}"
if __name__ == "__main__":
app.run(debug=True)