Search results

Loading Animation in JavaScript Tree Grid control

08 May 2023 / 2 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.

Copied to clipboard
import { TreeGrid, Page, Sort } from '@syncfusion/ej2-treegrid';
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
TreeGrid.Inject(Page, Sort);
    let data = new DataManager({
        url: '',
        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 }
Copied to clipboard
<!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="" />
    <script src=""></script>
    <script src="systemjs.config.js"></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>