"""
"""
import dash_mantine_components as dmc
from dash import Dash, html, dcc, _dash_renderer
import dash
# print(dash.__version__)
import dash_ag_grid as dag
import pandas as pd
import datetime
app = Dash(__name__, external_stylesheets=dmc.styles.ALL,
external_scripts=["https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"])
now = datetime.datetime.now()
df = pd.DataFrame({
'Column 1': [1, 2, 3, 4, 5, 6],
'Column 2': ['A', 'B', 'C', 'D', 'E', 'F'],
'Column 3': [now, now,
now, now, now, now],
'Column 4': [['testing']] *6
})
cols = [{'field': col} for col in df.columns]
cols[1]['cellEditor'] = {'function': 'DMC_Select'}
cols[1]['cellEditorParams'] = {'array': ['A', 'B', 'C', 'D', 'E', 'F']}
cols[1]['cellEditorPopup'] = True
cols[-1]['cellEditor'] = {'function': 'AllComponentEditors'}
cols[-1]['cellEditorParams'] = {'component': dcc.Dropdown(multi=True, options=['rawr', 'testing']),
}
cols[-1]['cellEditorPopup'] = True
cols[-1]['headerName'] = 'dcc.Dropdown(multi)'
cols[-1]['cellRendererParams'] = {'component': dcc.Dropdown(multi=True, options=['rawr', 'testing'])}
cols[-1]['cellRenderer'] = 'AllComponentRenderers'
cols[-2]['cellEditor'] = {'function': 'AllComponentEditors'}
cols[-2]['cellEditorParams'] = {'component': dmc.DateInput(highlightToday=True)}
cols[-2]['cellEditorPopup'] = True
cols[-2]['headerName'] = 'dmc.DateInput'
# cols[-2]['cellRenderer'] = 'AllComponentRenderers'
# cols[-2]['cellRendererParams'] = {'component': dmc.DateInput(highlightToday=True)}
grid = html.Div([
html.H1('Grid Page'),
dag.AgGrid(
id='grid_id',
columnDefs=cols,
columnSize="autoSize",
rowData=df.to_dict('records'),
defaultColDef={'editable': True},
dashGridOptions=dict(
enterMovesDown=True,
stopEditingWhenCellsLoseFocus=True,
),
enableEnterpriseModules=True
),
])
app.layout = dmc.MantineProvider(grid)
if __name__ == "__main__":
app.run(debug=True)