@@ -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 { GridFunctions } from '../../test-utils/grid-functions.spec' ;
1112import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
1213import { IgxGridTransaction } from '../tree-grid' ;
1314import { IgxTransactionService } from '../../services' ;
@@ -23,6 +24,7 @@ describe('Row Pinning #grid', () => {
2324 TestBed . configureTestingModule ( {
2425 declarations : [
2526 GridRowPinningComponent ,
27+ GridRowPinningWithMDVComponent ,
2628 GridRowPinningWithTransactionsComponent
2729 ] ,
2830 imports : [
@@ -274,6 +276,40 @@ describe('Row Pinning #grid', () => {
274276 expect ( grid . getRowByIndex ( 2 ) . rowID ) . toBe ( fix . componentInstance . data [ lastIndex ] ) ;
275277 } ) ;
276278 } ) ;
279+ describe ( 'Row pinning with Master Detail View' , ( ) => {
280+ beforeEach ( fakeAsync ( ( ) => {
281+ fix = TestBed . createComponent ( GridRowPinningWithMDVComponent ) ;
282+ fix . detectChanges ( ) ;
283+ grid = fix . componentInstance . instance ;
284+ tick ( ) ;
285+ fix . detectChanges ( ) ;
286+ } ) ) ;
287+
288+ it ( 'should be in view when expanded and pinning row to bottom of the grid.' , ( ) => {
289+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
290+ fix . detectChanges ( ) ;
291+ // pin 1st row
292+ const row = grid . getRowByIndex ( 0 ) ;
293+ row . pinned = true ;
294+ fix . detectChanges ( ) ;
295+
296+ GridFunctions . toggleMasterRow ( fix , grid . pinnedRows [ 0 ] ) ;
297+ fix . detectChanges ( ) ;
298+
299+
300+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
301+
302+ const firstRowIconName = GridFunctions . getRowExpandIconName ( grid . pinnedRows [ 0 ] ) ;
303+ const firstRowDetail = GridFunctions . getMasterRowDetail ( grid . pinnedRows [ 0 ] ) ;
304+ expect ( grid . expansionStates . size ) . toEqual ( 1 ) ;
305+ expect ( grid . expansionStates . has ( grid . pinnedRows [ 0 ] . rowID ) ) . toBeTruthy ( ) ;
306+ expect ( grid . expansionStates . get ( grid . pinnedRows [ 0 ] . rowID ) ) . toBeTruthy ( ) ;
307+ expect ( firstRowIconName ) . toEqual ( 'expand_more' ) ;
308+
309+ // check last pinned and expanded is fully in view
310+ expect ( firstRowDetail . getBoundingClientRect ( ) . bottom - grid . tbody . nativeElement . getBoundingClientRect ( ) . bottom ) . toBe ( 0 ) ;
311+ } ) ;
312+ } ) ;
277313
278314 describe ( ' Editing ' , ( ) => {
279315 beforeEach ( fakeAsync ( ( ) => {
@@ -374,6 +410,25 @@ export class GridRowPinningComponent {
374410 public instance : IgxGridComponent ;
375411}
376412
413+ @Component ( {
414+ template : `
415+ <igx-grid
416+ [pinning]='pinningConfig'
417+ [width]='"800px"'
418+ [height]='"500px"'
419+ [data]="data"
420+ [autoGenerate]="true">
421+ <ng-template igxGridDetail let-dataItem>
422+ <div>
423+ <div><span class='categoryStyle'>Country:</span> {{dataItem.Country}}</div>
424+ <div><span class='categoryStyle'>City:</span> {{dataItem.City}}</div>
425+ <div><span class='categoryStyle'>Address:</span> {{dataItem.Address}}</div>
426+ </div>
427+ </ng-template>
428+ </igx-grid>`
429+ } )
430+ export class GridRowPinningWithMDVComponent extends GridRowPinningComponent { }
431+
377432
378433@Component ( {
379434 template : `
@@ -388,6 +443,4 @@ export class GridRowPinningComponent {
388443 ` ,
389444 providers : [ { provide : IgxGridTransaction , useClass : IgxTransactionService } ]
390445} )
391- export class GridRowPinningWithTransactionsComponent extends GridRowPinningComponent {
392- public data = SampleTestData . contactInfoDataFull ( ) ;
393- }
446+ export class GridRowPinningWithTransactionsComponent extends GridRowPinningComponent { }
0 commit comments