@@ -8,6 +8,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
88import { ColumnPinningPosition , RowPinningPosition } from '../common/enums' ;
99import { IPinningConfig } from '../common/grid.interface' ;
1010import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
11+ import { verifyLayoutHeadersAreAligned , verifyDOMMatchesLayoutSettings } from '../../test-utils/helper-utils.spec' ;
1112import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
1213import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
1314import { IgxGridTransaction } from '../tree-grid' ;
@@ -25,6 +26,7 @@ describe('Row Pinning #grid', () => {
2526 TestBed . configureTestingModule ( {
2627 declarations : [
2728 GridRowPinningComponent ,
29+ GridRowPinningWithMRLComponent ,
2830 GridRowPinningWithMDVComponent ,
2931 GridRowPinningWithTransactionsComponent
3032 ] ,
@@ -465,6 +467,92 @@ describe('Row Pinning #grid', () => {
465467 } ) ;
466468
467469 } ) ;
470+ describe ( 'Row pinning with MRL' , ( ) => {
471+ beforeEach ( fakeAsync ( ( ) => {
472+ fix = TestBed . createComponent ( GridRowPinningWithMRLComponent ) ;
473+ fix . detectChanges ( ) ;
474+ grid = fix . componentInstance . instance ;
475+ tick ( ) ;
476+ fix . detectChanges ( ) ;
477+ } ) ) ;
478+
479+ it ( 'should pin/unpin correctly to top' , ( ) => {
480+ // pin
481+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
482+ fix . detectChanges ( ) ;
483+
484+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
485+ const pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
486+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
487+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
488+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
489+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . nativeElement ) . toBe ( grid . getRowByIndex ( 0 ) . nativeElement ) ;
490+
491+ expect ( grid . getRowByIndex ( 0 ) . pinned ) . toBeTruthy ( ) ;
492+ const gridPinnedRow = grid . pinnedRows [ 0 ] ;
493+ const pinnedRowCells = gridPinnedRow . cells . toArray ( ) ;
494+ const headerCells = grid . headerGroups . first . children . toArray ( ) ;
495+
496+ // headers are aligned to cells
497+ verifyLayoutHeadersAreAligned ( headerCells , pinnedRowCells ) ;
498+ verifyDOMMatchesLayoutSettings ( gridPinnedRow , fix . componentInstance . colGroups ) ;
499+
500+ // unpin
501+ const row = grid . pinnedRows [ 0 ] ;
502+ row . pinned = false ;
503+ fix . detectChanges ( ) ;
504+
505+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
506+ expect ( row . pinned ) . toBeFalsy ( ) ;
507+
508+ const gridUnpinnedRow = grid . getRowByIndex ( 1 ) ;
509+ const unpinnedRowCells = gridUnpinnedRow . cells . toArray ( ) ;
510+
511+ verifyLayoutHeadersAreAligned ( headerCells , unpinnedRowCells ) ;
512+ verifyDOMMatchesLayoutSettings ( gridUnpinnedRow , fix . componentInstance . colGroups ) ;
513+ } ) ;
514+
515+ it ( 'should pin/unpin correctly to bottom' , ( ) => {
516+
517+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
518+ fix . detectChanges ( ) ;
519+
520+ // pin
521+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
522+ fix . detectChanges ( ) ;
523+
524+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
525+ const pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
526+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
527+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
528+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
529+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . nativeElement )
530+ . toBe ( grid . getRowByIndex ( fix . componentInstance . data . length - 1 ) . nativeElement ) ;
531+
532+ expect ( grid . getRowByIndex ( fix . componentInstance . data . length - 1 ) . pinned ) . toBeTruthy ( ) ;
533+ const gridPinnedRow = grid . pinnedRows [ 0 ] ;
534+ const pinnedRowCells = gridPinnedRow . cells . toArray ( ) ;
535+ const headerCells = grid . headerGroups . first . children . toArray ( ) ;
536+
537+ // headers are aligned to cells
538+ verifyLayoutHeadersAreAligned ( headerCells , pinnedRowCells ) ;
539+ verifyDOMMatchesLayoutSettings ( gridPinnedRow , fix . componentInstance . colGroups ) ;
540+
541+ // unpin
542+ const row = grid . pinnedRows [ 0 ] ;
543+ row . pinned = false ;
544+ fix . detectChanges ( ) ;
545+
546+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
547+ expect ( row . pinned ) . toBeFalsy ( ) ;
548+
549+ const gridUnpinnedRow = grid . getRowByIndex ( 1 ) ;
550+ const unpinnedRowCells = gridUnpinnedRow . cells . toArray ( ) ;
551+
552+ verifyLayoutHeadersAreAligned ( headerCells , unpinnedRowCells ) ;
553+ verifyDOMMatchesLayoutSettings ( gridUnpinnedRow , fix . componentInstance . colGroups ) ;
554+ } ) ;
555+ } ) ;
468556} ) ;
469557
470558@Component ( {
@@ -487,6 +575,32 @@ export class GridRowPinningComponent {
487575 public instance : IgxGridComponent ;
488576}
489577
578+ @Component ( {
579+ template : `
580+ <igx-grid [data]="data" height="500px" [pinning]='pinningConfig'>
581+ <igx-column-layout *ngFor='let group of colGroups'>
582+ <igx-column *ngFor='let col of group.columns'
583+ [rowStart]="col.rowStart" [colStart]="col.colStart" [width]='col.width'
584+ [colEnd]="col.colEnd" [rowEnd]="col.rowEnd" [field]='col.field'></igx-column>
585+ </igx-column-layout>
586+ </igx-grid>
587+ `
588+ } )
589+ export class GridRowPinningWithMRLComponent extends GridRowPinningComponent {
590+ cols : Array < any > = [
591+ { field : 'ID' , rowStart : 1 , colStart : 1 } ,
592+ { field : 'CompanyName' , rowStart : 1 , colStart : 2 } ,
593+ { field : 'ContactName' , rowStart : 1 , colStart : 3 } ,
594+ { field : 'ContactTitle' , rowStart : 2 , colStart : 1 , rowEnd : 4 , colEnd : 4 } ,
595+ ] ;
596+ colGroups = [
597+ {
598+ group : 'group1' ,
599+ columns : this . cols
600+ }
601+ ] ;
602+ }
603+
490604@Component ( {
491605 template : `
492606 <igx-grid
0 commit comments