@@ -1075,6 +1075,58 @@ describe('IgxForOf directive -', () => {
10751075 }
10761076 } ) ;
10771077 } ) ;
1078+
1079+ describe ( 'remote virtual component with specified igxForOfTotalItemCount' , ( ) => {
1080+ configureTestSuite ( ) ;
1081+ let fix : ComponentFixture < RemoteVirtCountComponent > ;
1082+
1083+ beforeEach ( async ( ( ) => {
1084+ TestBed . configureTestingModule ( {
1085+ declarations : [
1086+ TestIgxForOfDirective ,
1087+ RemoteVirtCountComponent
1088+ ] ,
1089+ imports : [ IgxForOfModule ]
1090+ } ) . compileComponents ( ) ;
1091+ } ) ) ;
1092+
1093+ beforeEach ( ( ) => {
1094+ fix = TestBed . createComponent ( RemoteVirtCountComponent ) ;
1095+ fix . componentRef . hostView . detectChanges ( ) ;
1096+ fix . detectChanges ( ) ;
1097+
1098+ displayContainer = fix . nativeElement . querySelector ( 'igx-display-container' ) ;
1099+ verticalScroller = fix . nativeElement . querySelector ( 'igx-virtual-helper' ) ;
1100+ } ) ;
1101+
1102+ it ( 'should apply remote virtualization correctly' , async ( ) => {
1103+ // verify data is loaded
1104+ let rowsRendered = displayContainer . children ;
1105+ let data = fix . componentInstance . data . source . getValue ( ) ;
1106+ for ( let i = 0 ; i < rowsRendered . length ; i ++ ) {
1107+ expect ( rowsRendered [ i ] . textContent . trim ( ) )
1108+ . toBe ( data [ i ] . toString ( ) ) ;
1109+ }
1110+
1111+ // scroll down
1112+ expect ( ( ) => {
1113+ verticalScroller . scrollTop = 10000 ;
1114+ fix . detectChanges ( ) ;
1115+ fix . componentRef . hostView . detectChanges ( ) ;
1116+ } ) . not . toThrow ( ) ;
1117+
1118+ await wait ( ) ;
1119+
1120+ // verify data is loaded
1121+ rowsRendered = displayContainer . children ;
1122+ data = fix . componentInstance . data . source . getValue ( ) ;
1123+ for ( let i = fix . componentInstance . parentVirtDir . state . startIndex ; i < rowsRendered . length ; i ++ ) {
1124+ expect ( rowsRendered [ i ] . textContent . trim ( ) )
1125+ . toBe ( data [ i ] . toString ( ) ) ;
1126+ }
1127+ } ) ;
1128+ } ) ;
1129+
10781130 describe ( 'no width and height component' , ( ) => {
10791131 configureTestSuite ( ) ;
10801132 let fix : ComponentFixture < NoWidthAndHeightComponent > ;
@@ -1518,10 +1570,15 @@ export class LocalService {
15181570 private _records : BehaviorSubject < any [ ] > ;
15191571 private dataStore : any [ ] ;
15201572
1573+ public count : Observable < number > ;
1574+ private _count : BehaviorSubject < number > ;
1575+
15211576 constructor ( ) {
15221577 this . dataStore = [ ] ;
15231578 this . _records = new BehaviorSubject ( [ ] ) ;
15241579 this . records = this . _records . asObservable ( ) ;
1580+ this . _count = new BehaviorSubject ( null ) ;
1581+ this . count = this . _count . asObservable ( ) ;
15251582 }
15261583
15271584 public getData ( data ?: IForOfState , cb ?: ( any ) => void ) : any {
@@ -1534,6 +1591,11 @@ export class LocalService {
15341591 }
15351592 }
15361593
1594+ public getCount ( ) {
1595+ const count = 1000 ;
1596+ this . _count . next ( count ) ;
1597+ }
1598+
15371599 public generateData ( start , end ) {
15381600 const dummyData = [ ] ;
15391601 for ( let i = start ; i < end ; i ++ ) {
@@ -1588,6 +1650,51 @@ export class RemoteVirtualizationComponent implements OnInit, AfterViewInit {
15881650 }
15891651}
15901652
1653+ @Component ( {
1654+ template : `
1655+ <div #container [style.width]='width' [style.height]='height'>
1656+ <ng-template #scrollContainer let-rowData [igxForOf]="data | async" igxForTest
1657+ [igxForTotalItemCount]="count | async"
1658+ [igxForContainerSize]='height'
1659+ [igxForItemSize]='"50px"'
1660+ (onChunkPreload)="dataLoading($event)">
1661+ <div [style.display]="'flex'" [style.height]="'50px'">
1662+ {{rowData}}
1663+ </div>
1664+ </ng-template>
1665+ </div>
1666+ ` ,
1667+ providers : [ LocalService ]
1668+ } )
1669+ export class RemoteVirtCountComponent implements OnInit , AfterViewInit {
1670+ public height = '500px' ;
1671+ public data ;
1672+ public count : Observable < number > ;
1673+
1674+ @ViewChild ( 'scrollContainer' , { read : TestIgxForOfDirective , static : true } )
1675+ public parentVirtDir : TestIgxForOfDirective < any > ;
1676+
1677+ @ViewChild ( 'container' , { read : ViewContainerRef , static : true } )
1678+ public container : ViewContainerRef ;
1679+
1680+ constructor ( private localService : LocalService ) { }
1681+ public ngOnInit ( ) : void {
1682+ this . data = this . localService . records ;
1683+ this . count = this . localService . count ;
1684+ }
1685+
1686+ public ngAfterViewInit ( ) {
1687+ this . localService . getCount ( ) ;
1688+ this . localService . getData ( this . parentVirtDir . state ) ;
1689+ }
1690+
1691+ dataLoading ( evt ) {
1692+ this . localService . getData ( evt , ( ) => {
1693+ this . parentVirtDir . cdr . detectChanges ( ) ;
1694+ } ) ;
1695+ }
1696+ }
1697+
15911698@Component ( {
15921699 template : `
15931700 <div class="container">
0 commit comments