In React Ag-Grid, if a user pastes data into multiple cells at once, the valueSetter gets called for each cell that was pasted. This significantly slows down rendering, because if a user wants to paste into 10 cells, then valueSetter gets called 10 times (the data in my Ag-Grid is managed using redux, so I must dispatch an update when changes occur in Ag-Grid). Ideally, the valueSetter could group all of the changes and then only get called once.
Here is my onChange function:
const onChange = (params) => {
const uuid = params.data['UUID'];
var newValue = params.newValue;
const field = params.colDef.field;
const updates = [{tableName: props.tableName, newValues: [newValue], updateColumnNames:[field], uuids:[uuid]}];
dispatch(updateTableMulti(updates));
}
The onChange function is associated with each column through the columndDefinition parameter, as
colDefs.push({'field': colName,
'headerName': columnHeader,
...,
'valueSetter': (params) => {onChange(params); return true},
headerTooltip: headerTooltip,
...type
})
I’ve tried using the onPasteStart and onPasteEnd parameters of AgGridReact to indicate when onChange should group together updates, but, the onChange function is getting called before onPasteStart even registers.