Hello everybody,
i am facing two issues that i suspect it has something to do with Grid formatting.
- When i delete the content of a cell in some columns the value 0,0… (zero) is asserted do this cell. This does not happen in every column. In the most of the columns i get an empty cell
- I have used ‘locale’ to change the decimal notation (point to comma). When i insert a decimal value to the cells in certain columns (same columns mentioned in first issue) i have to use point instead of comma notation. This does not happen in every column. In the most of the columns of the grid comma notation can be used.
dash==2.17.0
dash-ag-grid==31.2.0
The issues occur only in the columns: ‘col_F’, ‘col_G’, ‘col_H’, ‘col_I’. In all the remaining columns there are no issues. The part of the code is attached below.
column_def = []
for col in parameter_ef_esp.columns:
if col == 'col_A':
column_def.append({'headerName': col, # Name of table displayed in app
'field': col, # ID of table (needs to be the same as Excel sheet column name)
"rowDrag": True, # only need to activate on the first row for all to be draggable
"checkboxSelection": True, # only need to activate on the first row
"cellStyle": {'textAlign': 'center'}})
elif col in ['col_B', ]:
column_def.append({'headerName': col, # Name of table displayed in app
'field': col, # ID of table (needs to be the same as Excel sheet column name)
"cellStyle": {'textAlign': 'center'}})
else:
if col == 'col_G':
cell_format = '\'.6f\''
elif col == 'col_I':
cell_format = '\'.3f\''
else:
cell_format = '\'.2f\''
column_def.append({'headerName': col, # Name of table displayed in app
'field': col, # ID of table (needs to be the same as Excel sheet column name)
"cellStyle": {'textAlign': 'center'},
"valueFormatter": {
"function": f"""
(params.value || params.value == 0) ? {self.locale_de}.format({cell_format})
(params.value):null;
"""
},
# "valueFormatter": {"function": f"{locale_de}.format('.2f')(params.value)"},
# 'cellEditor': 'agNumberCellEditor',
})
default_col_def = {
# "filter": True,
"filter": "agNumberColumnFilter",
"resizable": True,
"sortable": True,
"editable": True,
"floatingFilter": True,
"minWidth": 200,
"wrapHeaderText": True,
"autoHeaderHeight": True,
# "cellStyle": {'wordBreak': 'normal', 'whiteSpace': 'pre'},
}
grid = dag.AgGrid(
id="snd_grid",
className="ag-theme-alpine-dark",
columnDefs=column_def,
# rowData=df.to_dict("records"),
rowData=parameter_ef_esp.to_dict(orient='records'),
# rowData=data,
columnSize="sizeToFit",
defaultColDef=default_col_def,
dashGridOptions={"undoRedoCellEditing": True, "undoRedoCellEditingLimit": 20, 'rowSelection': "multiple",
# 'rowDragManaged': True,
'domLayout': 'autoHeight',
"pagination": True, "animateRows": True,
"paginationPageSize": 20},
style={"height": "100%", "width": "100%"},
)