@@ -32,7 +32,7 @@ import {
32
32
import { getResizeObserver } from '../core/utils' ;
33
33
import 'igniteui-trial-watermark' ;
34
34
import { Subject , pipe , fromEvent , noop } from 'rxjs' ;
35
- import { takeUntil , first , filter , throttleTime , map , shareReplay } from 'rxjs/operators' ;
35
+ import { takeUntil , first , filter , throttleTime , map , shareReplay , takeWhile } from 'rxjs/operators' ;
36
36
import { cloneArray , flatten , mergeObjects , compareMaps , resolveNestedPath , isObject , PlatformUtil } from '../core/utils' ;
37
37
import { GridColumnDataType } from '../data-operations/data-util' ;
38
38
import { FilteringLogic , IFilteringExpression } from '../data-operations/filtering-expression.interface' ;
@@ -1234,8 +1234,8 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
1234
1234
public toolbar : QueryList < IgxGridToolbarComponent > ;
1235
1235
1236
1236
/** @hidden @internal */
1237
- @ContentChild ( IgxPaginatorComponent )
1238
- protected paginatorCmpt : IgxPaginatorComponent ;
1237
+ @ContentChildren ( IgxPaginatorComponent )
1238
+ protected paginatorCmpts : QueryList < IgxPaginatorComponent > ;
1239
1239
1240
1240
/**
1241
1241
* @hidden @internal
@@ -1491,6 +1491,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
1491
1491
}
1492
1492
1493
1493
public set perPage ( val : number ) {
1494
+ this . _perPage = val ;
1494
1495
if ( this . paginator ) {
1495
1496
this . paginator . perPage = val ;
1496
1497
}
@@ -2616,7 +2617,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
2616
2617
*/
2617
2618
public set pagingState ( value ) {
2618
2619
this . _pagingState = value ;
2619
- if ( this . paginator ) {
2620
+ if ( this . paginator && ! this . _init ) {
2620
2621
this . paginator . totalRecords = value . metadata . countRecords ;
2621
2622
}
2622
2623
}
@@ -2852,7 +2853,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
2852
2853
2853
2854
/** @hidden @internal */
2854
2855
public get paginator ( ) {
2855
- return this . paginatorCmpt ;
2856
+ return this . paginatorCmpts ?. first ;
2856
2857
}
2857
2858
2858
2859
/**
@@ -3510,30 +3511,31 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
3510
3511
public ngAfterContentInit ( ) {
3511
3512
this . setupColumns ( ) ;
3512
3513
this . toolbar . changes . pipe ( takeUntil ( this . destroy$ ) , filter ( ( ) => ! this . _init ) ) . subscribe ( ( ) => this . notifyChanges ( true ) ) ;
3513
- if ( this . paginator ) {
3514
- this . paginator . perPage = this . paginator . perPage || this . _perPage ;
3515
- this . paginator . pageChange . pipe ( takeUntil ( this . destroy$ ) , filter ( ( ) => ! this . _init ) )
3516
- . subscribe ( ( page : number ) => {
3517
- this . pageChange . emit ( page ) ;
3518
- } ) ;
3519
- this . paginator . pagingDone . pipe ( takeUntil ( this . destroy$ ) , filter ( ( ) => ! this . _init ) )
3520
- . subscribe ( ( args : IPageEventArgs ) => {
3521
- this . selectionService . clear ( true ) ;
3522
- this . pagingDone . emit ( { previous : args . previous , current : args . current } ) ;
3523
- this . crudService . endEdit ( false ) ;
3524
- this . pipeTrigger ++ ;
3525
- this . navigateTo ( 0 ) ;
3526
- this . notifyChanges ( ) ;
3527
- } ) ;
3528
- this . paginator . perPageChange . pipe ( takeUntil ( this . destroy$ ) , filter ( ( ) => ! this . _init ) )
3529
- . subscribe ( ( perPage : number ) => {
3530
- this . selectionService . clear ( true ) ;
3531
- this . perPageChange . emit ( perPage ) ;
3532
- this . page = 0 ;
3533
- this . crudService . endEdit ( false ) ;
3534
- this . notifyChanges ( ) ;
3535
- } ) ;
3536
- }
3514
+ this . paginatorCmpts . changes . pipe ( takeUntil ( this . destroy$ ) , filter ( ( ) => ! this . _init ) ) . subscribe ( ( ) => {
3515
+ if ( this . paginator ) {
3516
+ this . paginator . pageChange . pipe ( takeWhile ( ( ) => ! ! this . paginator ) , filter ( ( ) => ! this . _init ) )
3517
+ . subscribe ( ( page : number ) => {
3518
+ this . pageChange . emit ( page ) ;
3519
+ } ) ;
3520
+ this . paginator . pagingDone . pipe ( takeWhile ( ( ) => ! ! this . paginator ) , filter ( ( ) => ! this . _init ) )
3521
+ . subscribe ( ( args : IPageEventArgs ) => {
3522
+ this . selectionService . clear ( true ) ;
3523
+ this . pagingDone . emit ( { previous : args . previous , current : args . current } ) ;
3524
+ this . crudService . endEdit ( false ) ;
3525
+ this . pipeTrigger ++ ;
3526
+ this . navigateTo ( 0 ) ;
3527
+ this . notifyChanges ( ) ;
3528
+ } ) ;
3529
+ this . paginator . perPageChange . pipe ( takeWhile ( ( ) => ! ! this . paginator ) , filter ( ( ) => ! this . _init ) )
3530
+ . subscribe ( ( perPage : number ) => {
3531
+ this . selectionService . clear ( true ) ;
3532
+ this . perPageChange . emit ( perPage ) ;
3533
+ this . page = 0 ;
3534
+ this . crudService . endEdit ( false ) ;
3535
+ this . notifyChanges ( ) ;
3536
+ } ) ;
3537
+ }
3538
+ } ) ;
3537
3539
if ( this . actionStrip ) {
3538
3540
this . actionStrip . menuOverlaySettings . outlet = this . outlet ;
3539
3541
}
@@ -3628,7 +3630,12 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
3628
3630
} ) ;
3629
3631
3630
3632
// Keep the stream open for future subscribers
3631
- this . rendered$ . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( noop ) ;
3633
+ this . rendered$ . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( ) => {
3634
+ if ( this . paginator ) {
3635
+ this . paginator . perPage = this . _perPage ;
3636
+ this . paginator . totalRecords = this . totalRecords ;
3637
+ }
3638
+ } ) ;
3632
3639
Promise . resolve ( ) . then ( ( ) => this . rendered . next ( true ) ) ;
3633
3640
}
3634
3641
@@ -6881,13 +6888,13 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
6881
6888
protected scrollTo ( row : any | number , column : any | number , inCollection = this . _filteredSortedUnpinnedData ) : void {
6882
6889
let delayScrolling = false ;
6883
6890
6884
- if ( this . paging && typeof ( row ) !== 'number' ) {
6891
+ if ( this . paginator && typeof ( row ) !== 'number' ) {
6885
6892
const rowIndex = inCollection . indexOf ( row ) ;
6886
6893
const page = Math . floor ( rowIndex / this . perPage ) ;
6887
6894
6888
- if ( this . page !== page ) {
6895
+ if ( this . paginator . page !== page ) {
6889
6896
delayScrolling = true ;
6890
- this . page = page ;
6897
+ this . paginator . page = page ;
6891
6898
}
6892
6899
}
6893
6900
0 commit comments