We just wrapped up AG Studio Launch Week See what we shipped




Core Features

Advanced Features

JavaScript Data GridAG Grid Error #26

Full Error Text

Grid API function `<fnName>()` cannot be called as the grid has been destroyed.
 Either clear local references to the grid api, when it is destroyed, or check `gridApi.isDestroyed()` to avoid calling methods against a destroyed grid.
 To run logic when the grid is about to be destroyed use the `gridPreDestroyed` event. See: <preDestroyLink>
To show this error text in the dev console, enable development validations .

Grid API Called After Destroy Copy Link

The grid API object outlives the grid. Once the grid is destroyed its methods remain callable but have nothing to act on, so the call named in the message did nothing.

This is a warning rather than an error because the call is ignored, but it usually means part of your application still believes the grid is there, so whatever the call was meant to achieve has silently not happened.

Error #200 covers an API method that is unavailable because its module is not registered. Arriving here means the grid itself is gone.

Where the stale call comes from Copy Link

Almost always a reference to the API captured earlier and used after teardown:

  • A timer or interval that outlives the component holding the grid.
  • A subscription or event listener, such as a store, websocket or router, still holding the API in its closure.
  • A promise or async function that resolves after the grid has gone, for example a fetch whose then calls setGridOption.
  • A resize or intersection observer that was never disconnected.

In each case the fix is to cancel the thing that outlived the grid, as part of the same teardown that destroys the grid.

Guarding a call you cannot move Copy Link

Where a call genuinely may or may not happen after teardown, isDestroyed() lets you check first:

if (!api.isDestroyed()) {
    api.redrawRows();
}

This is a guard of last resort. It stops the warning, but the call is still not doing what it was written to do, so if the work matters the teardown is the thing to fix.

Doing work before the grid goes Copy Link

To run something as the grid is torn down, such as saving state or releasing resources, use the gridPreDestroyed event, which fires while the grid is still usable. See Grid Pre-Destroyed.

The following documentation pages should provide additional context / guidance on how to resolve this error.