I have a fairly wide AgGrid table (36 columns)
For some aggregate columns I’m using valueGetter and valueSetter as I need to pass all rowData later in my app.
For some reason, the columns that are using Getter/Setter don’t get returned in rowData until I have scrolled to the actual column. Im not using virtualRowData.
Here is some code and my problem column in question. Im not sure where my issue is.
{
"headerName": "2025 - Total",
"children": [
{
"headerName": y,
"valueGetter": {"function": f"params.getValue('g_{y}') + params.getValue('input_{y}');"},
"valueSetter": {"function": f"valueSetterFinal(params, '{y}')"},
"valueFormatter": {"function": "d3.format(',.1f')(params.value)"},
"editable": False,
"cellDataType": "number",
"width": 70,
}
for x, y in {
"f_A": "A1",
"f_B": "B2",
"f_C": "C3",
"f_D": "D4",
"f_E": "E5",
}.items()
],
}
// JS Function
dagfuncs.valueSetterFinal = (params, region) => {
const newVal = params.newValue;
const valueChanged = params.data[`f_${region}`] !== newVal;
if (valueChanged) {
params.data[`f_${region}`] = newVal;
}
return valueChanged;
};
Then I use a callback to get rowData
@app.callback(
Output("sl-total", "rowData"),
Input("sl-cg", "cellValueChanged"),
Input("sl-parts", "cellValueChanged"),
State("sl-cg", "rowData"),
State("sl-parts", "rowData"),
# prevent_initial_call=True,
)
def update_total(cg_event, parts_event, sl_cg, sl_parts):
# Convert rowData to DataFrame
df_cg = pd.DataFrame(sl_cg)
df_parts = pd.DataFrame(sl_parts)
# Add the two DataFrames, treating NaNs as 0 during addition.
# Sets index so it doesnt concat the Account column.
df_total = (
df_cg.set_index("Accounts")
.add(df_parts.set_index("Accounts"), fill_value=0)
.reset_index()
)
# Convert DataFrame back to dictionary
return df_total.to_dict("records")