I am receiving "invalid row index for ensureIndexVisible" for valid row indexes.
For example:
invalid row index for ensureIndexVisible: 0
invalid row index for ensureIndexVisible: 3
I am not implementing getRowNodeId
. Instead, I am letting AG Grid build the IDs, but the problem occurs either way I try it.
Here's the related code in the component:
gridOptions = {
onGridReady: (params: any) => {
params.api.sizeColumnsToFit();
},
onRowClicked: (params: any) => {
localStorage.setItem('lastDeveloper', params.node.id.toString());
this.router.navigate(['developers', params.node.data.id], { state: params.node.data });
},
onFirstDataRendered: (params: any) => {
const lastDeveloperSelected = localStorage.getItem('lastDeveloper');
if (lastDeveloperSelected) {
params.api.ensureIndexVisible(lastDeveloperSelected, 'middle');
}
}
}
This appears to have been a type problem, and ensuring the index was a number
and not a string
made the difference:
params.api.ensureIndexVisible(+lastDeveloperSelected, 'middle');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With