Framework:Javascript GridAngular GridReact GridVue Grid

JavaScript Grid: Overlay Component

Overlay components allow you to add your own overlays to AG Grid. Use these when the provided overlays do not meet your requirements.

Simple Loading Overlay Component

Below is a simple example of loading overlay class:

class CustomLoadingCellRenderer {
   init(params) {
       this.eGui = document.createElement('div');
       this.eGui.innerHTML = `
           <div class="ag-custom-loading-cell" style="padding-left: 10px; line-height: 25px;">  
               <i class="fas fa-spinner fa-pulse"></i> 
               <span>${params.loadingMessage} </span>
           </div>
       `;
   }

   getGui() {
       return this.eGui;
   }
}

Simple No-Rows Overlay Component

Below is a simple example of no rows overlay class:

class CustomNoRowsOverlay {
   init(params) {
       this.eGui = document.createElement('div');
       this.eGui.innerHTML = `
           <div class="ag-overlay-loading-center" style="background-color: lightcoral;">   
               <i class="far fa-frown"> ${params.noRowsMessageFunc()} </i>
           </div>
       `;
   }

   getGui() {
       return this.eGui;
   }
}

Example: Custom Overlay Components

The example below demonstrates how to provide custom overlay components to the grid. Notice the following:

  • Custom Loading Overlay Renderer is supplied by name via gridOptions.loadingOverlayComponent.
  • Custom Loading Overlay Renderer Parameters are supplied using gridOptions loadingOverlayComponentParams.
  • Custom No Rows Overlay Renderer is supplied by name via gridOptions.noRowsOverlayComponent.
  • Custom No Rows Overlay Renderer Parameters are supplied using gridOptions.noRowsOverlayComponentParams.

Overlay Component Interfaces

Loading Overlay

Implement this interface to provide a custom overlay when data is being loaded.

interface ILoadingOverlayComp {
   // mandatory methods

   // The init(params) method is called on the overlay once. See below for details on the parameters.
   init(params: ILoadingOverlayParams): void;

   // Returns the DOM element for this overlay
   getGui(): HTMLElement;
}

No Rows Overlay

Implement this interface to provide a custom overlay when no rows loaded.

interface INoRowsOverlayComp {
   // mandatory methods

   // The init(params) method is called on the overlay once. See below for details on the parameters.
   init(params: INoRowsOverlayParams): void;

   // Returns the DOM element for this overlay
   getGui(): HTMLElement;
}

The interface for the overlay parameters is as follows:

Loading Overlay Params Interface

interface ILoadingOverlayParams {
    // The grid API
    api: GridApi;
}

No Rows Overlay Params Interface

interface INoRowsOverlayParams {
    // The grid API
    api: GridApi;
}

Registering Overlay Components

See the section registering custom components for details on registering and using custom overlays.