@@ -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' ;
@@ -24,6 +25,7 @@ describe('Row Pinning #grid', () => {
2425 TestBed . configureTestingModule ( {
2526 declarations : [
2627 GridRowPinningComponent ,
28+ GridRowPinningWithMRLComponent ,
2729 GridRowPinningWithMDVComponent ,
2830 GridRowPinningWithTransactionsComponent
2931 ] ,
@@ -389,6 +391,92 @@ describe('Row Pinning #grid', () => {
389391 } ) ;
390392
391393 } ) ;
394+ describe ( 'Row pinning with MRL' , ( ) => {
395+ beforeEach ( fakeAsync ( ( ) => {
396+ fix = TestBed . createComponent ( GridRowPinningWithMRLComponent ) ;
397+ fix . detectChanges ( ) ;
398+ grid = fix . componentInstance . instance ;
399+ tick ( ) ;
400+ fix . detectChanges ( ) ;
401+ } ) ) ;
402+
403+ it ( 'should pin/unpin correctly to top' , ( ) => {
404+ // pin
405+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
406+ fix . detectChanges ( ) ;
407+
408+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
409+ const pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
410+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
411+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
412+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
413+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . nativeElement ) . toBe ( grid . getRowByIndex ( 0 ) . nativeElement ) ;
414+
415+ expect ( grid . getRowByIndex ( 0 ) . pinned ) . toBeTruthy ( ) ;
416+ const gridPinnedRow = grid . pinnedRows [ 0 ] ;
417+ const pinnedRowCells = gridPinnedRow . cells . toArray ( ) ;
418+ const headerCells = grid . headerGroups . first . children . toArray ( ) ;
419+
420+ // headers are aligned to cells
421+ verifyLayoutHeadersAreAligned ( headerCells , pinnedRowCells ) ;
422+ verifyDOMMatchesLayoutSettings ( gridPinnedRow , fix . componentInstance . colGroups ) ;
423+
424+ // unpin
425+ const row = grid . pinnedRows [ 0 ] ;
426+ row . pinned = false ;
427+ fix . detectChanges ( ) ;
428+
429+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
430+ expect ( row . pinned ) . toBeFalsy ( ) ;
431+
432+ const gridUnpinnedRow = grid . getRowByIndex ( 1 ) ;
433+ const unpinnedRowCells = gridUnpinnedRow . cells . toArray ( ) ;
434+
435+ verifyLayoutHeadersAreAligned ( headerCells , unpinnedRowCells ) ;
436+ verifyDOMMatchesLayoutSettings ( gridUnpinnedRow , fix . componentInstance . colGroups ) ;
437+ } ) ;
438+
439+ it ( 'should pin/unpin correctly to bottom' , ( ) => {
440+
441+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
442+ fix . detectChanges ( ) ;
443+
444+ // pin
445+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
446+ fix . detectChanges ( ) ;
447+
448+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
449+ const pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
450+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
451+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
452+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
453+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . nativeElement )
454+ . toBe ( grid . getRowByIndex ( fix . componentInstance . data . length - 1 ) . nativeElement ) ;
455+
456+ expect ( grid . getRowByIndex ( fix . componentInstance . data . length - 1 ) . pinned ) . toBeTruthy ( ) ;
457+ const gridPinnedRow = grid . pinnedRows [ 0 ] ;
458+ const pinnedRowCells = gridPinnedRow . cells . toArray ( ) ;
459+ const headerCells = grid . headerGroups . first . children . toArray ( ) ;
460+
461+ // headers are aligned to cells
462+ verifyLayoutHeadersAreAligned ( headerCells , pinnedRowCells ) ;
463+ verifyDOMMatchesLayoutSettings ( gridPinnedRow , fix . componentInstance . colGroups ) ;
464+
465+ // unpin
466+ const row = grid . pinnedRows [ 0 ] ;
467+ row . pinned = false ;
468+ fix . detectChanges ( ) ;
469+
470+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
471+ expect ( row . pinned ) . toBeFalsy ( ) ;
472+
473+ const gridUnpinnedRow = grid . getRowByIndex ( 1 ) ;
474+ const unpinnedRowCells = gridUnpinnedRow . cells . toArray ( ) ;
475+
476+ verifyLayoutHeadersAreAligned ( headerCells , unpinnedRowCells ) ;
477+ verifyDOMMatchesLayoutSettings ( gridUnpinnedRow , fix . componentInstance . colGroups ) ;
478+ } ) ;
479+ } ) ;
392480} ) ;
393481
394482@Component ( {
@@ -410,6 +498,32 @@ export class GridRowPinningComponent {
410498 public instance : IgxGridComponent ;
411499}
412500
501+ @Component ( {
502+ template : `
503+ <igx-grid [data]="data" height="500px" [pinning]='pinningConfig'>
504+ <igx-column-layout *ngFor='let group of colGroups'>
505+ <igx-column *ngFor='let col of group.columns'
506+ [rowStart]="col.rowStart" [colStart]="col.colStart" [width]='col.width'
507+ [colEnd]="col.colEnd" [rowEnd]="col.rowEnd" [field]='col.field'></igx-column>
508+ </igx-column-layout>
509+ </igx-grid>
510+ `
511+ } )
512+ export class GridRowPinningWithMRLComponent extends GridRowPinningComponent {
513+ cols : Array < any > = [
514+ { field : 'ID' , rowStart : 1 , colStart : 1 } ,
515+ { field : 'CompanyName' , rowStart : 1 , colStart : 2 } ,
516+ { field : 'ContactName' , rowStart : 1 , colStart : 3 } ,
517+ { field : 'ContactTitle' , rowStart : 2 , colStart : 1 , rowEnd : 4 , colEnd : 4 } ,
518+ ] ;
519+ colGroups = [
520+ {
521+ group : 'group1' ,
522+ columns : this . cols
523+ }
524+ ] ;
525+ }
526+
413527@Component ( {
414528 template : `
415529 <igx-grid
0 commit comments