Reputation: 451
I'm using AG-Grid enterprise edition (trail); and having an issue as in this stackoverflow post.
When the grid data is loaded, the values of one column are all empty. In an event handler, the column value on some rows will be set. The column filter is updated the first time column values are changed. From the second time on, the column filter dropdown list is not correct.
(The left side dropdown is when column values are changed for the first time, the right side is when the values are changed again after)
Here is my code:
const onCreateBatchRequested = (rules: CreateMigrationBatchSchema) => {
if (gridApi) {
let [notPlannedUnitNodes, selectedUnitNodes] = selectPlanningItemsForBatch(gridApi, rules)
notPlannedUnitNodes.forEach((node) => {
if (node.data.planningState || node.data.plannedMigrationBatch) {
node.data.planningState = ItemState.NOT_PLANNED
node.data.plannedMigrationBatch = ""
node.updateData(node.data)
}
node.setSelected(false)
})
selectedUnitNodes.forEach((node) => {
node.data.planningState = ItemState.PLANNING
node.data.plannedMigrationBatch = rules.migrationBatchName
node.updateData(node.data)
node.setSelected(true)
})
}
}
Tried adding
gridApi.applyTransaction({update: transaction})
or/and
gridApi.getColumnFilterInstance("...").refresh()
on top of the above code. The dropdown update seems to be ok, but I'd have to toggle the dropdown option to get the expected value displayed in the grid.
Upvotes: 0
Views: 31
Reputation: 451
OK, I need 3 api calls to get the result I want:
updatedRowNodes.forEach((node) => {node.updateData(node.data)})
gridApi.applyTransaction({update: updatedRowNodes})
gridApi.redrawRows({rowNodes: updatedRowNodes})
Upvotes: 0