Loading animation in EJ2 TypeScript Treegrid control

27 Apr 20235 minutes to read

The Tree Grid displays a loading indicator while the data is being fetched and bound to the tree grid during initial rendering, refreshing, and after performing any tree grid actions like sorting, paging and more.

The tree grid supports two indicator types, which can be enabled by setting the loadingIndicator.indicatorType property to Spinner or Shimmer. The default value of the indicator type is Spinner.

In the following sample, the Shimmer indicator is displayed while the tree grid is loading and refreshing when using the remote data.

import { TreeGrid, Page, Sort } from '@syncfusion/ej2-treegrid';
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
TreeGrid.Inject(Page, Sort);
    let data = new DataManager({
        url: 'https://ej2services.syncfusion.com/production/web-services/api/SelfReferenceData',
        adaptor: new WebApiAdaptor(),
        crossDomain: true
    let treegrid: TreeGrid = new TreeGrid(
            dataSource: data,
            hasChildMapping: 'isParent',
            idMapping: 'TaskID',
            parentIdMapping: 'ParentItem',
            height: 400,
            treeColumnIndex: 1,
            allowPaging: true,
            allowSorting: true,
            loadingIndicator: { indicatorType: 'Shimmer' },
            columns: [
                { field: 'TaskID', headerText: 'Task ID', width: 120, textAlign: 'Right' },
                { field: 'TaskName', headerText: 'Task Name', width: 240, textAlign: 'Left' },
                { field: 'StartDate', headerText: 'Start Date', width: 140, textAlign: 'Right', type: 'date', format: 'yMd' },
                { field: 'Duration', headerText: 'Duration', width: 130, textAlign: 'Right' },
                { field: 'Progress', headerText: 'Progress', width: 130 },
            pageSettings: { pageCount: 3 }
<!DOCTYPE html>
<html lang="en">

    <title>EJ2 Tree Grid</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript Tree Grid Control" />
    <meta name="author" content="Syncfusion" />
     <!-- Syncfusion Essential JS 2 Styles -->
    <link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/material.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
    #container {
    visibility: hidden;

#loader {
  color: #008cff;
  font-family: 'Helvetica Neue','calibiri';
  font-size: 14px;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
    <div id='loader'>Loading....</div>
    <div id='container'>
        <div id='TreeGrid'></div>