Hi,
I am looking for the following hybrid resizing behavior for ag grid and I am not sure if it could be done out of the box by setting some grid parameters
I can achieve the result I want by double clicking (excel-style) the columns to resize to contents.
The end-state (which I want to achieve as start state) should look similar to the end of the clip, while still being responsive for the last column as of then. So in essence, columns which are excluded from responsive resize should resize to the content.
grid_crashList = dag.AgGrid(
id="crashListTable",
rowData=df2.to_dict('records'),
className="ag-theme-balham",
columnDefs=[
{
'headerName': 'High',
'children': [
{ 'headerName':'Date', 'field': 'HighTS', 'colId':'HighTS','type': 'dateColumn',
"valueGetter": {"function": dff("params.data.HighTS")},
"valueFormatter": {"function": f"d3.timeFormat('%d/%m/%Y')({ dff('params.data.HighTS') })"},
"suppressSizeToFit":True,
},
{
'headerName':'Close ($)', 'field': 'HighValue', 'colId':'HighValue', 'type': 'numericColumn' ,
"valueFormatter": {"function": "d3.format('(.2f')(params.value)"},
"suppressSizeToFit":True,
},
],
},
{
'headerName': 'Low',
'children': [
{ 'headerName':'Date', 'field': 'LowTS', 'colId':'LowTS','type': ['dateColumn'],
"valueGetter": {"function": dff("params.data.LowTS")},
"valueFormatter": {"function": f"d3.timeFormat('%d/%m/%Y')({dff('params.data.LowTS')})"},
"suppressSizeToFit":True
},
{ 'headerName':'Close ($)', 'field': 'LowValue', 'colId':'LowValue', 'type': 'numericColumn',
"valueFormatter": {"function": "d3.format('(.2f')(params.value)"},
"suppressSizeToFit":True
},
{ 'headerName':'Loss (%)', 'field': 'DrawDownPct', 'colId':'DrawDownPct', 'type': 'numericColumn',
"valueFormatter": {"function": "params.value !== null ? d3.format('.2%')(params.value/100) : ''"},
"suppressSizeToFit":True
},
{ 'headerName':'Duration (d)', 'field': 'DrawDownTime', 'colId':'DrawDownTime', 'type': 'numericColumn',
"suppressSizeToFit":True },
]
},
{
'headerName': 'Recovery',
'children': [
{ 'headerName':'Date', 'field': 'RecoveryTS', 'colId':'RecoveryTS','type': 'dateColumn',
"valueGetter": {"function": dff("params.data.RecoveryTS")},
"valueFormatter": {"function": f"params.value !== null ? d3.timeFormat('%d/%m/%Y')({dff('params.data.RecoveryTS')}) :''"},
"suppressSizeToFit":True
},
{ 'headerName':'Close ($)', 'field': 'RecoveryValue', 'colId':'RecoveryValue', 'type': 'numericColumn',
"valueFormatter": {"function": "params.value !== null ? d3.format('(.2f')(params.value) : ''"},
"suppressSizeToFit":True
},
{ 'headerName':'Gain (%)', 'field': 'RecoveryPct', 'colId':'RecoveryPct', 'type': 'numericColumn',
"valueFormatter": {"function": "params.value !== null ? d3.format('.2%')(params.value/100) : ''"},
"suppressSizeToFit":True
},
{ 'headerName':'Duration (d)', 'field': 'RecoveryTime', 'colId':'RecoveryTime', 'type': 'numericColumn',
"valueFormatter": {"function": "params.value !== 'NaN' ? params.value : ''"},
"suppressSizeToFit":True
},
]
},
{ 'headerName':'Ongoing', 'field': 'Ongoing', 'colId':'Ongoing',
"valueFormatter": {"function": "params.value === true ? '✔️' : ''"},
},
],
defaultColDef={"resizable": True, "sortable": True, "filter": True},
columnSize="responsiveSizeToFit",
)