1
- import { Component , OnInit } from '@angular/core' ;
2
- import { VirtualScrollService } from '@syncfusion/ej2-ng-grids' ;
1
+ import { Component , OnInit , ViewEncapsulation , ViewChild } from '@angular/core' ;
2
+ import { VirtualScrollService , GridComponent } from '@syncfusion/ej2-ng-grids' ;
3
3
4
4
@Component ( {
5
5
selector : 'ej2-gridvirtual' ,
6
6
templateUrl : 'virtualization.html' ,
7
+ styleUrls : [ 'virtualization.style.css' ] ,
8
+ encapsulation : ViewEncapsulation . None ,
7
9
providers : [ VirtualScrollService ]
8
10
} )
9
11
export class VirtualizationComponent implements OnInit {
10
- public data : Object [ ] = [ ] ;
12
+ public virtualData : Object [ ] = [ ] ;
11
13
public names : string [ ] = [ 'hardire' , 'abramjo01' , 'aubucch01' , "Hook" , "Rumpelstiltskin" , "Belle" , "Emma" , "Regina" , "Aurora" , "Elsa" , "Anna" , "Snow White" , "Prince Charming" , "Cora" , "Zelena" , "August" , "Mulan" , "Graham" , "Discord" , "Will" , "Robin Hood" , "Jiminy Cricket" , "Henry" , "Neal" , "Red" ,
12
14
"Aaran" , "Aaren" , "Aarez" , "Aarman" , "Aaron" , "Aaron-James" , "Aarron" , "Aaryan" , "Aaryn" , "Aayan" , "Aazaan" , "Abaan" , "Abbas" , "Abdallah" , "Abdalroof" , "Abdihakim" , "Abdirahman" , "Abdisalam" , "Abdul" , "Abdul-Aziz" , "Abdulbasir" , "Abdulkadir" , "Abdulkarem" , "Abdulkhader" , "Abdullah" , "Abdul-Majeed" , "Abdulmalik" , "Abdul-Rehman" , "Abdur" , "Abdurraheem" , "Abdur-Rahman" , "Abdur-Rehmaan" , "Abel" , "Abhinav" , "Abhisumant" , "Abid" , "Abir" , "Abraham" , "Abu" , "Abubakar" , "Ace" , "Adain" , "Adam" , "Adam-James" , "Addison" , "Addisson" , "Adegbola" , "Adegbolahan" , "Aden" , "Adenn" , "Adie" , "Adil" , "Aditya" , "Adnan" , "Adrian" , "Adrien" , "Aedan" , "Aedin" , "Aedyn" , "Aeron" , "Afonso" , "Ahmad" , "Ahmed" , "Ahmed-Aziz" , "Ahoua" , "Ahtasham" , "Aiadan" , "Aidan" , "Aiden" , "Aiden-Jack" , "Aiden-Vee" ] ;
13
15
14
- public ngOnInit ( ) : void {
15
- for ( let i : number = 0 ; i < 5000 ; i ++ ) {
16
- this . data . push ( {
17
- "FIELD1" : this . names [ Math . floor ( Math . random ( ) * this . names . length ) ] ,
18
- "FIELD2" : 1967 + ( i % 10 ) ,
19
- "FIELD3" : Math . floor ( Math . random ( ) * 200 ) ,
20
- "FIELD4" : Math . floor ( Math . random ( ) * 100 ) ,
21
- "FIELD5" : Math . floor ( Math . random ( ) * 2000 ) ,
22
- "FIELD6" : Math . floor ( Math . random ( ) * 1000 ) ,
23
- "FIELD7" : Math . floor ( Math . random ( ) * 100 ) ,
24
- "FIELD8" : Math . floor ( Math . random ( ) * 10 ) ,
25
- "FIELD9" : Math . floor ( Math . random ( ) * 10 ) ,
26
- "FIELD10" : Math . floor ( Math . random ( ) * 100 ) ,
27
- "FIELD11" : Math . floor ( Math . random ( ) * 100 ) ,
28
- "FIELD12" : Math . floor ( Math . random ( ) * 1000 ) ,
29
- "FIELD13" : Math . floor ( Math . random ( ) * 10 ) ,
30
- "FIELD14" : Math . floor ( Math . random ( ) * 10 ) ,
31
- "FIELD15" : Math . floor ( Math . random ( ) * 1000 ) ,
32
- "FIELD16" : Math . floor ( Math . random ( ) * 200 ) ,
33
- "FIELD17" : Math . floor ( Math . random ( ) * 300 ) ,
34
- "FIELD18" : Math . floor ( Math . random ( ) * 400 ) ,
35
- "FIELD19" : Math . floor ( Math . random ( ) * 500 ) ,
36
- "FIELD20" : Math . floor ( Math . random ( ) * 700 ) ,
37
- "FIELD21" : Math . floor ( Math . random ( ) * 800 ) ,
38
- "FIELD22" : Math . floor ( Math . random ( ) * 1000 ) ,
39
- "FIELD23" : Math . floor ( Math . random ( ) * 2000 ) ,
40
- "FIELD24" : Math . floor ( Math . random ( ) * 150 ) ,
41
- "FIELD25" : Math . floor ( Math . random ( ) * 1000 ) ,
42
- "FIELD26" : Math . floor ( Math . random ( ) * 100 ) ,
43
- "FIELD27" : Math . floor ( Math . random ( ) * 400 ) ,
44
- "FIELD28" : Math . floor ( Math . random ( ) * 600 ) ,
45
- "FIELD29" : Math . floor ( Math . random ( ) * 500 ) ,
46
- "FIELD30" : Math . floor ( Math . random ( ) * 300 ) ,
16
+ @ViewChild ( 'grid' )
17
+ public grid : GridComponent ;
18
+ public ngOnInit ( ) : void { }
19
+
20
+ onClick = ( args : any ) => {
21
+ for ( let i : number = 0 ; i < 100000 ; i ++ ) {
22
+ if ( ! this . virtualData . length ) {
23
+ this . show ( ) ;
24
+ }
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 ) ,
47
56
} ) ;
48
57
}
58
+ this . grid . dataSource = this . virtualData ;
59
+ this . grid . refresh ( ) ;
60
+ }
61
+ show ( ) : void {
62
+ document . getElementById ( 'popup' ) . style . display = 'inline-block' ;
63
+ }
64
+ hide ( ) : void {
65
+ document . getElementById ( 'popup' ) . style . display = 'none' ;
49
66
}
50
67
}
0 commit comments