Skip to content

Commit d7c0a61

Browse files
Martin DragnevMartin Dragnev
Martin Dragnev
authored and
Martin Dragnev
committed
feat(igxGrid): Row Pinning + MDV integration #6640
1 parent a8c4f30 commit d7c0a61

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -3044,6 +3044,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
30443044
public set expansionStates(value) {
30453045
this._expansionStates = new Map<any, boolean>(value);
30463046
this.expansionStatesChange.emit(this._expansionStates);
3047+
this.notifyChanges(true);
30473048
if (this.gridAPI.grid) {
30483049
this.cdr.detectChanges();
30493050
}

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

+59-1
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

1213
describe('Row Pinning #grid', () => {
1314
const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ';
@@ -18,7 +19,8 @@ describe('Row Pinning #grid', () => {
1819
beforeAll(async(() => {
1920
TestBed.configureTestingModule({
2021
declarations: [
21-
GridRowPinningComponent
22+
GridRowPinningComponent,
23+
GridRowPinningWithMDVComponent
2224
],
2325
imports: [
2426
NoopAnimationsModule,
@@ -217,6 +219,40 @@ describe('Row Pinning #grid', () => {
217219
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
218220
});
219221
});
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+
});
220256
});
221257

222258
@Component({
@@ -237,3 +273,25 @@ export class GridRowPinningComponent {
237273
@ViewChild(IgxGridComponent, { read: IgxGridComponent, static: true })
238274
public instance: IgxGridComponent;
239275
}
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

Comments
 (0)