As per the requirement we will get values from api and those rows should be pre-selected when loading Ag Grid.
this.columnDefs = [
{
headerName: 'Option Code',
field: 'Option',
maxWidth: 125,
checkboxSelection: true,
}
];
this.addOption = ["000005","000010","000026"]; // External data
On Grid Ready:
onGridReady(params) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
this.gridApi.getRenderedNodes().forEach(function (node:any) {
node.setSelected(this.addOption.includes(
node.data.Option.toString()
));
});
}
We are trying below code to pre-select default checkbox and it is not working.
selectAllAmerican(val) {
this.gridApi.getRenderedNodes().forEach(function (node:any) {
node.setSelected(val.includes(node.data.Option.toString()));
});
}
The above code is working when we used under Get button. Kindly review and guide us.