@@ -8,6 +8,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
8
8
import { ColumnPinningPosition , RowPinningPosition } from '../common/enums' ;
9
9
import { IPinningConfig } from '../common/grid.interface' ;
10
10
import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
11
+ import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
11
12
12
13
describe ( 'Row Pinning #grid' , ( ) => {
13
14
const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ' ;
@@ -18,7 +19,8 @@ describe('Row Pinning #grid', () => {
18
19
beforeAll ( async ( ( ) => {
19
20
TestBed . configureTestingModule ( {
20
21
declarations : [
21
- GridRowPinningComponent
22
+ GridRowPinningComponent ,
23
+ GridRowPinningWithMDVComponent
22
24
] ,
23
25
imports : [
24
26
NoopAnimationsModule ,
@@ -217,6 +219,40 @@ describe('Row Pinning #grid', () => {
217
219
expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
218
220
} ) ;
219
221
} ) ;
222
+ fdescribe ( 'Row pinning with Master Detail View' , ( ) => {
223
+ beforeEach ( fakeAsync ( ( ) => {
224
+ fix = TestBed . createComponent ( GridRowPinningWithMDVComponent ) ;
225
+ fix . detectChanges ( ) ;
226
+ grid = fix . componentInstance . instance ;
227
+ tick ( ) ;
228
+ fix . detectChanges ( ) ;
229
+ } ) ) ;
230
+
231
+ it ( 'should pin/unpin via row pinned setter.' , ( ) => {
232
+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
233
+ fix . detectChanges ( ) ;
234
+ // pin 2nd row
235
+ const row = grid . getRowByIndex ( 0 ) ;
236
+ row . pinned = true ;
237
+ fix . detectChanges ( ) ;
238
+
239
+ GridFunctions . toggleMasterRow ( fix , grid . pinnedRows [ 0 ] ) ;
240
+ fix . detectChanges ( ) ;
241
+
242
+
243
+ expect ( grid . pinnedRecords . length ) . toBe ( 1 ) ;
244
+
245
+ const firstRowIconName = GridFunctions . getRowExpandIconName ( grid . pinnedRows [ 0 ] ) ;
246
+ const firstRowDetail = GridFunctions . getMasterRowDetail ( grid . pinnedRows [ 0 ] ) ;
247
+ expect ( grid . expansionStates . size ) . toEqual ( 1 ) ;
248
+ expect ( grid . expansionStates . has ( grid . pinnedRows [ 0 ] . rowID ) ) . toBeTruthy ( ) ;
249
+ expect ( grid . expansionStates . get ( grid . pinnedRows [ 0 ] . rowID ) ) . toBeTruthy ( ) ;
250
+ expect ( firstRowIconName ) . toEqual ( 'expand_more' ) ;
251
+
252
+ // check last pinned and expanded is fully in view
253
+ expect ( firstRowDetail . getBoundingClientRect ( ) . bottom - grid . tbody . nativeElement . getBoundingClientRect ( ) . bottom ) . toBe ( 0 ) ;
254
+ } ) ;
255
+ } ) ;
220
256
} ) ;
221
257
222
258
@Component ( {
@@ -237,3 +273,25 @@ export class GridRowPinningComponent {
237
273
@ViewChild ( IgxGridComponent , { read : IgxGridComponent , static : true } )
238
274
public instance : IgxGridComponent ;
239
275
}
276
+
277
+ @Component ( {
278
+ template : `
279
+ <igx-grid
280
+ [pinning]='pinningConfig'
281
+ [width]='"800px"'
282
+ [height]='"500px"'
283
+ [data]="data"
284
+ [autoGenerate]="true">
285
+ <ng-template igxGridDetail let-dataItem>
286
+ <div>
287
+ <div><span class='categoryStyle'>Country:</span> {{dataItem.Country}}</div>
288
+ <div><span class='categoryStyle'>City:</span> {{dataItem.City}}</div>
289
+ <div><span class='categoryStyle'>Address:</span> {{dataItem.Address}}</div>
290
+ </div>
291
+ </ng-template>
292
+ </igx-grid>`
293
+ } )
294
+
295
+ export class GridRowPinningWithMDVComponent extends GridRowPinningComponent {
296
+
297
+ }
0 commit comments