@@ -15,53 +15,63 @@ export class VirtualizationComponent implements OnInit {
1515
1616 @ViewChild ( 'grid' )
1717 public grid : GridComponent ;
18- public ngOnInit ( ) : void { }
18+ public date1 : number ;
19+ public date2 : number ;
20+ public flag : boolean = true ;
21+ public ngOnInit ( ) : void { }
1922
2023 onClick = ( args : any ) => {
21- for ( let i : number = 0 ; i < 100000 ; i ++ ) {
22- if ( ! this . virtualData . length ) {
23- this . show ( ) ;
24+ this . show ( ) ;
25+ if ( ! this . virtualData . length ) {
26+ for ( let i : number = 0 ; i < 100000 ; i ++ ) {
27+ this . virtualData . push ( {
28+ 'FIELD1' : this . names [ Math . floor ( Math . random ( ) * this . names . length ) ] ,
29+ 'FIELD2' : 1967 + ( i % 10 ) ,
30+ 'FIELD3' : Math . floor ( Math . random ( ) * 200 ) ,
31+ 'FIELD4' : Math . floor ( Math . random ( ) * 100 ) ,
32+ 'FIELD5' : Math . floor ( Math . random ( ) * 2000 ) ,
33+ 'FIELD6' : Math . floor ( Math . random ( ) * 1000 ) ,
34+ 'FIELD7' : Math . floor ( Math . random ( ) * 100 ) ,
35+ 'FIELD8' : Math . floor ( Math . random ( ) * 10 ) ,
36+ 'FIELD9' : Math . floor ( Math . random ( ) * 10 ) ,
37+ 'FIELD10' : Math . floor ( Math . random ( ) * 100 ) ,
38+ 'FIELD11' : Math . floor ( Math . random ( ) * 100 ) ,
39+ 'FIELD12' : Math . floor ( Math . random ( ) * 1000 ) ,
40+ 'FIELD13' : Math . floor ( Math . random ( ) * 10 ) ,
41+ 'FIELD14' : Math . floor ( Math . random ( ) * 10 ) ,
42+ 'FIELD15' : Math . floor ( Math . random ( ) * 1000 ) ,
43+ 'FIELD16' : Math . floor ( Math . random ( ) * 200 ) ,
44+ 'FIELD17' : Math . floor ( Math . random ( ) * 300 ) ,
45+ 'FIELD18' : Math . floor ( Math . random ( ) * 400 ) ,
46+ 'FIELD19' : Math . floor ( Math . random ( ) * 500 ) ,
47+ 'FIELD20' : Math . floor ( Math . random ( ) * 700 ) ,
48+ 'FIELD21' : Math . floor ( Math . random ( ) * 800 ) ,
49+ 'FIELD22' : Math . floor ( Math . random ( ) * 1000 ) ,
50+ 'FIELD23' : Math . floor ( Math . random ( ) * 2000 ) ,
51+ 'FIELD24' : Math . floor ( Math . random ( ) * 150 ) ,
52+ 'FIELD25' : Math . floor ( Math . random ( ) * 1000 ) ,
53+ 'FIELD26' : Math . floor ( Math . random ( ) * 100 ) ,
54+ 'FIELD27' : Math . floor ( Math . random ( ) * 400 ) ,
55+ 'FIELD28' : Math . floor ( Math . random ( ) * 600 ) ,
56+ 'FIELD29' : Math . floor ( Math . random ( ) * 500 ) ,
57+ 'FIELD30' : Math . floor ( Math . random ( ) * 300 ) ,
58+ } ) ;
2459 }
25- this . virtualData . push ( {
26- 'FIELD1' : this . names [ Math . floor ( Math . random ( ) * this . names . length ) ] ,
27- 'FIELD2' : 1967 + ( i % 10 ) ,
28- 'FIELD3' : Math . floor ( Math . random ( ) * 200 ) ,
29- 'FIELD4' : Math . floor ( Math . random ( ) * 100 ) ,
30- 'FIELD5' : Math . floor ( Math . random ( ) * 2000 ) ,
31- 'FIELD6' : Math . floor ( Math . random ( ) * 1000 ) ,
32- 'FIELD7' : Math . floor ( Math . random ( ) * 100 ) ,
33- 'FIELD8' : Math . floor ( Math . random ( ) * 10 ) ,
34- 'FIELD9' : Math . floor ( Math . random ( ) * 10 ) ,
35- 'FIELD10' : Math . floor ( Math . random ( ) * 100 ) ,
36- 'FIELD11' : Math . floor ( Math . random ( ) * 100 ) ,
37- 'FIELD12' : Math . floor ( Math . random ( ) * 1000 ) ,
38- 'FIELD13' : Math . floor ( Math . random ( ) * 10 ) ,
39- 'FIELD14' : Math . floor ( Math . random ( ) * 10 ) ,
40- 'FIELD15' : Math . floor ( Math . random ( ) * 1000 ) ,
41- 'FIELD16' : Math . floor ( Math . random ( ) * 200 ) ,
42- 'FIELD17' : Math . floor ( Math . random ( ) * 300 ) ,
43- 'FIELD18' : Math . floor ( Math . random ( ) * 400 ) ,
44- 'FIELD19' : Math . floor ( Math . random ( ) * 500 ) ,
45- 'FIELD20' : Math . floor ( Math . random ( ) * 700 ) ,
46- 'FIELD21' : Math . floor ( Math . random ( ) * 800 ) ,
47- 'FIELD22' : Math . floor ( Math . random ( ) * 1000 ) ,
48- 'FIELD23' : Math . floor ( Math . random ( ) * 2000 ) ,
49- 'FIELD24' : Math . floor ( Math . random ( ) * 150 ) ,
50- 'FIELD25' : Math . floor ( Math . random ( ) * 1000 ) ,
51- 'FIELD26' : Math . floor ( Math . random ( ) * 100 ) ,
52- 'FIELD27' : Math . floor ( Math . random ( ) * 400 ) ,
53- 'FIELD28' : Math . floor ( Math . random ( ) * 600 ) ,
54- 'FIELD29' : Math . floor ( Math . random ( ) * 500 ) ,
55- 'FIELD30' : Math . floor ( Math . random ( ) * 300 ) ,
56- } ) ;
60+ this . grid . dataSource = this . virtualData ;
5761 }
58- this . grid . dataSource = this . virtualData ;
62+ this . flag = true ;
63+ this . date1 = new Date ( ) . getTime ( ) ;
5964 this . grid . refresh ( ) ;
6065 }
6166 show ( ) : void {
6267 document . getElementById ( 'popup' ) . style . display = 'inline-block' ;
6368 }
6469 hide ( ) : void {
70+ if ( this . flag && this . date1 ) {
71+ this . date2 = new Date ( ) . getTime ( ) ;
72+ document . getElementById ( 'performanceTime' ) . innerHTML = 'Time Taken: ' + ( this . date2 - this . date1 ) + 'ms' ;
73+ this . flag = false ;
74+ }
6575 document . getElementById ( 'popup' ) . style . display = 'none' ;
6676 }
6777}
0 commit comments