Search results

Loading Animation in React TreeGrid component

02 Feb 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, filtering, 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.

Source
Preview
App.jsx
App.tsx
Copied to clipboard
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
import { ColumnDirective, ColumnsDirective, Inject, Page, TreeGridComponent, Sort } from '@syncfusion/ej2-react-treegrid';
import * as React from 'react';
function App() {
    const pageSettings = { pageCount: 3 };
    const data = new DataManager({
        adaptor: new WebApiAdaptor,
        crossDomain: true,
        url: 'https://ej2services.syncfusion.com/production/web-services/api/SelfReferenceData'
    });
    return <TreeGridComponent dataSource={data} hasChildMapping='isParent' treeColumnIndex={1} idMapping='TaskID' parentIdMapping='ParentItem' height='400' loadingIndicator={{ indicatorType: 'Shimmer' }} allowPaging={true} allowSorting={true} pageSettings={pageSettings}>
        <ColumnsDirective>
            <ColumnDirective field='TaskID' headerText='Task ID' width='120' textAlign='Right'/>
            <ColumnDirective field='TaskName' headerText='Task Name' width='240' textAlign='Left'/>
            <ColumnDirective field='StartDate' headerText='Start Date' width='140' format='yMd' textAlign='Right' type='date'/>
            <ColumnDirective field='Duration' headerText='Duration' width='130' textAlign='Right'/>
            <ColumnDirective field='Progress' headerText='Progress' width='130'/>
        </ColumnsDirective>
        <Inject services={[Page, Sort]}/>
    </TreeGridComponent>;
}
;
export default App;
Copied to clipboard
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
import { ColumnDirective, ColumnsDirective, Inject, Page, TreeGridComponent, Sort, PageSettingsModel } from '@syncfusion/ej2-react-treegrid';
import * as React from 'react';

function App() {
    const pageSettings: PageSettingsModel = { pageCount: 3 };
    const data = new DataManager({
        adaptor: new WebApiAdaptor,
        crossDomain: true,
        url: 'https://ej2services.syncfusion.com/production/web-services/api/SelfReferenceData'
    });
    return <TreeGridComponent dataSource={data} hasChildMapping='isParent' treeColumnIndex={1} idMapping='TaskID' parentIdMapping='ParentItem' height='400' loadingIndicator= {{ indicatorType: 'Shimmer' }} allowPaging={true} allowSorting={true} pageSettings={pageSettings}>
        <ColumnsDirective>
            <ColumnDirective field='TaskID' headerText='Task ID' width='120' textAlign='Right'/>
            <ColumnDirective field='TaskName' headerText='Task Name' width='240' textAlign='Left'/>
            <ColumnDirective field='StartDate' headerText='Start Date' width='140' format='yMd' textAlign='Right' type='date' />
            <ColumnDirective field='Duration' headerText='Duration' width='130' textAlign='Right' />
            <ColumnDirective field='Progress' headerText='Progress' width='130' />
        </ColumnsDirective>
        <Inject services={[Page, Sort]}/>
    </TreeGridComponent>
};
export default App;