Skip to content

Commit cc90be5

Browse files
authored
Merge pull request #6909 from IgniteUI/mdragnev/row-pinning-mdv
feat(igxGrid): Row Pinning + MDV integration
2 parents b08a4b7 + b21bca7 commit cc90be5

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,6 +3080,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
30803080
public set expansionStates(value) {
30813081
this._expansionStates = new Map<any, boolean>(value);
30823082
this.expansionStatesChange.emit(this._expansionStates);
3083+
this.notifyChanges(true);
30833084
if (this.gridAPI.grid) {
30843085
this.cdr.detectChanges();
30853086
}

projects/igniteui-angular/src/lib/grids/grid/row-pinning.spec.ts

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
88
import { ColumnPinningPosition, RowPinningPosition } from '../common/enums';
99
import { IPinningConfig } from '../common/grid.interface';
1010
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
11+
import { GridFunctions } from '../../test-utils/grid-functions.spec';
1112
import { SortingDirection } from '../../data-operations/sorting-expression.interface';
1213
import { IgxGridTransaction } from '../tree-grid';
1314
import { 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

Comments
 (0)