Hi, I have just transferred over to using dash AG Grid rather than DataTable which I had been using for a while but I have run into a few issues, firstly with the layout, secondly with the grid.
My layout has two side panel and a central container. The idea is that these all fit on the full screen and there is no scrolling of the page involved. Using the AG Grid has now pushed the right hand panel below the first panel and container and the only change has been to use the grid instead of the dataTable. I have attempted to simplify my code and provide an example which mimics the same layout and right hand panel:
example_app.py
from dash import Dash, html, dcc
import dash_mantine_components as dmc
import dash_ag_grid as dag
import pandas as pd
app = Dash(__name__)
def dash_ag_grid(df: pd.DataFrame, id):
grid = dag.AgGrid(
id=id,
className="ag-theme-alpine compact ag-center-cols-clipper",
rowData=df.to_dict("records"),
columnDefs = [
{'field': 'props', 'minWidth': 50, 'maxWidth': 100, "wrapText": True, "autoHeight": True, "cellStyle": {"wordBreak": "normal", "lineHeight": "unset"}},
{'field': 'values', 'minWidth': 100, 'maxWidth': 150, "wrapText": True, "autoHeight": True, "cellStyle": {"wordBreak": "normal", "lineHeight": "unset"}},
],
columnSize="sizeToFit",
rowClass="bg-light",
style={"width": "250px", "height": None},
defaultColDef={},
dashGridOptions = {
'headerHeight': 0,
"domLayout": "autoHeight",
},
)
return grid
def panel_content():
det_info = []
f_data = {
'props': [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
'values': [100, 110, 120, 130, 140, 150, 160, 170, 180, 190]
}
df_data = pd.DataFrame.from_records({'props': ["address"], 'values': ["example address"]}, columns=['props', 'values'])
det_info.append(dash_ag_grid(df_data, "ag-address"))
feat_details = []
df_data = pd.DataFrame.from_records(f_data, columns=['props', 'values'])
feat_details.append(dmc.AccordionItem([dmc.AccordionControl("example data"), dmc.AccordionPanel(dash_ag_grid(df_data, {"type": "ag-detailed-info", "item": "example_data"})),], value="example_data",))
det_info.append(dmc.Accordion(children=feat_details, chevronPosition='left', classNames={"control": "dmc-accordion-control-3", "content": "dmc-accordion-content"}))
return det_info
app.layout = html.Div(
[dmc.Grid(
children=[
dmc.Stack([
dmc.Group([
dmc.Col(html.Div("side_pane_left", style={'background-color': 'CornflowerBlue', 'margin': 0, 'padding': 0, "height": "100vh", "width": "250px"}), span="content"),
dmc.Col(html.Div("centre_map", style={'background-color': 'PeachPuff', 'margin': 0, 'padding': 0, "height": "100vh", 'width': 'calc(100vw - 2 * 250px)'}), span="auto"),
dmc.Col(html.Div(panel_content(), style={'background-color': 'Gainsboro', 'margin': 0, 'padding': 0, "height": "100vh", "width": "250px","overflow-y": "auto", "overflow-x": "hidden"}), span="content"),
], style={"height": "100vh"}, grow=True, spacing="0px"),
], style={"height": "100vh"}, spacing="0px", align="stretch", justify="center")
],
gutter="0px",
)],
style={'margin': 0, 'padding': 0})
if __name__ == '__main__':
app.run(debug=True)
custom_css.css (in assets folder)
.dmc-accordion-control-3 {
padding-top: 5px;
padding-bottom: 5px;
padding-left: 0px;
padding-right: 0px;
background-color: DarkSalmon;
}
.dmc-accordion-content {
padding-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
}
.ag-theme-alpine.compact {
--ag-grid-size: 3px;
--ag-font-size: 10px;
--ag-borders: none;
--ag-row-border-style: solid;
--ag-row-border-width: 1px;
--ag-row-border-color: Gainsboro;
}
.ag-center-cols-clipper {
min-height: unset !important;
}
(apologies for not tidying up the styling on the elements)
You can see at the figure below, the layout is not performing correctly / as desired:
The second item you can see in the image above; the single row grid is smaller than the 150px, and even with .css update with min-height: unset !important;
it still leaves the blank space. Appears that it is not performing as per docs: grid size
Any help here would be amazing as have been going round and round trying to solve these issues.