1- import React , { useRef } from "react" ;
1+ import React , { useEffect , useRef , useState } from "react" ;
22import ReactDOM from "react-dom/client" ;
33import "./index.css" ;
4+ import "igniteui-react-grids/grids/themes/light/bootstrap.css" ;
5+ import { OrdersTreeData } from "./OrdersData" ;
46
7+ import { IgrButton } from "igniteui-react" ;
58import {
69 IgrGridToolbar ,
710 IgrGridToolbarActions ,
811 IgrGridToolbarExporter ,
912 IgrGridToolbarTitle ,
10- IgrHierarchicalGridModule ,
11- } from "igniteui-react-grids" ;
12- import {
1313 IgrTreeGrid ,
14- IgrColumn ,
14+ IgrColumn
1515} from "igniteui-react-grids" ;
16- import { IgrButton } from "igniteui-react" ;
1716
18- import "igniteui-react-grids/grids/themes/light/bootstrap.css" ;
19- import { OrdersTreeData } from "./OrdersData" ;
20-
21- IgrHierarchicalGridModule . register ( ) ;
2217
23- export default function App ( ) {
18+ export default function TreeGridDataExportingIndicatorSample ( ) {
2419 const ordersData = new OrdersTreeData ( ) ;
25- const treeGridRef = useRef < IgrTreeGrid > ( null ) ;
26- const toolbarRef = useRef < IgrGridToolbar > ( null ) ;
27-
28- const localData : any [ ] = [ ] ;
29- for ( let i = 0 ; i < 100 ; i ++ ) {
30- for ( let c = 0 ; c < ordersData . length ; c ++ ) {
31- const original = ordersData [ c ] ;
32- localData . push ( {
33- ...original ,
34- ID : original . ID + ( i * ordersData . length ) ,
35- ParentID : original . ParentID === - 1 ? - 1 : original . ParentID + ( i * ordersData . length )
36- } ) ;
37- }
38- }
39-
20+ const [ localData , setLocalData ] = useState ( [ ] ) ;
21+ const [ showProgress , setShowProgress ] = useState ( false ) ;
4022
41- function showProgress ( ) {
42- toolbarRef . current . showProgress = true ;
23+ useEffect ( ( ) => {
24+ const data : any [ ] = [ ] ;
25+ for ( let i = 0 ; i < 1000 ; i ++ ) {
26+ for ( let c = 0 ; c < ordersData . length ; c ++ ) {
27+ const original = ordersData [ c ] ;
28+ data . push ( {
29+ ...original ,
30+ ID : original . ID + ( i * ordersData . length ) ,
31+ ParentID : original . ParentID === - 1 ? - 1 : original . ParentID + ( i * ordersData . length )
32+ } ) ;
33+ }
34+ }
35+ setLocalData ( data ) ;
36+ } , [ ] ) ;
4337
38+ const setupProgressVisibility = ( ) => {
39+ setShowProgress ( true ) ;
40+
4441 setTimeout ( ( ) => {
45- toolbarRef . current . showProgress = false ;
42+ setShowProgress ( false ) ;
4643 } , 5000 ) ;
4744 }
4845
4946 return (
5047 < div className = "container sample ig-typography" >
5148 < div className = "container fill" >
5249 < IgrTreeGrid
53- ref = { treeGridRef }
5450 data = { localData }
5551 autoGenerate = { false }
5652 primaryKey = "ID"
5753 foreignKey = "ParentID"
5854 height = "350px"
5955 >
60- < IgrGridToolbar ref = { toolbarRef } key = "toolbar" >
56+ < IgrGridToolbar key = "toolbar" showProgress = { showProgress } >
6157 < IgrGridToolbarTitle key = "toolbarTitle" >
6258 < span key = "toolbarTitleText" > Tree Grid Toolbar</ span >
6359 </ IgrGridToolbarTitle >
64- < IgrButton key = "btn" onClick = { showProgress } >
60+ < IgrButton key = "btn" onClick = { setupProgressVisibility } >
6561 < span key = "simulate" > Simulate long running operation</ span >
6662 </ IgrButton >
6763 < IgrGridToolbarActions key = "toolbarActions" >
@@ -84,4 +80,4 @@ export default function App() {
8480
8581// rendering above component in the React DOM
8682const root = ReactDOM . createRoot ( document . getElementById ( "root" ) ) ;
87- root . render ( < App /> ) ;
83+ root . render ( < TreeGridDataExportingIndicatorSample /> ) ;
0 commit comments