Overlay components allow you to add your own overlays to AG Grid. Use these when the provided overlays do not meet your requirements.
Below is an example of overlay component with custom loadingMessage:
export default props => {
return (
<div className="ag-custom-loading-cell" style={{paddingLeft: '10px', lineHeight: '25px'}}>
<i className="fas fa-spinner fa-pulse"></i> <span> {props.loadingMessage}</span>
</div>
);
};
const gridOptions: GridOptions = {
...
loadingOverlayComponent: CustomLoadingOverlay,
loadingOverlayComponentParams: {
loadingMessage: 'One moment please...',
},
}
Below is an example of a no rows overlay component with custom noRowsMessageFunc() params:
export default props => {
return (
<div className="ag-overlay-loading-center" style={{backgroundColor: 'lightcoral', height: '9%'}}>
<i className="far fa-frown"> {props.noRowsMessageFunc()}</i>
</div>
);
};
const gridOptions: GridOptions = {
...
noRowsOverlayComponent: CustomNoRowsOverlay,
noRowsOverlayComponentParams: {
noRowsMessageFunc: () => 'Sorry - no rows! at: ' + new Date(),
},
}
The example below demonstrates how to provide custom overlay components to the grid. Notice the following:
gridOptions.loadingOverlayComponent.gridOptions loadingOverlayComponentParams.gridOptions.noRowsOverlayComponent.gridOptions.noRowsOverlayComponentParams.Any valid React component can be an Overlay. When a custom Overlay Component is instantiated within both a template and the Grid API will be made available on props:
See the section registering custom components for details on registering and using custom overlays.