Skip to content

Commit bcda167

Browse files
authored
Merge pull request #6967 from IgniteUI/dkamburov/row-pin-hiding
test(row-pinning): Add test for row pinning and hiding #6640
2 parents f2ae421 + 9da7381 commit bcda167

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

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

+44
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,50 @@ describe('Row Pinning #grid', () => {
699699
verifyDOMMatchesLayoutSettings(gridUnpinnedRow, fix.componentInstance.colGroups);
700700
});
701701
});
702+
describe(' Hiding', () => {
703+
beforeEach(fakeAsync(() => {
704+
fix = TestBed.createComponent(GridRowPinningComponent);
705+
fix.detectChanges();
706+
grid = fix.componentInstance.instance;
707+
tick();
708+
fix.detectChanges();
709+
}));
710+
711+
it('should hide columns in pinned and unpinned area', () => {
712+
// pin 2nd data row
713+
grid.pinRow(fix.componentInstance.data[1]);
714+
fix.detectChanges();
715+
const hiddenCol = grid.columns[1];
716+
hiddenCol.hidden = true;
717+
fix.detectChanges();
718+
719+
const pinnedCells = grid.pinnedRows[0].cells;
720+
expect(pinnedCells.filter(cell => cell.column.field === hiddenCol.field).length).toBe(0);
721+
722+
const unpinnedCells = grid.rowList.first.cells;
723+
expect(unpinnedCells.filter(cell => cell.column.field === hiddenCol.field).length).toBe(0);
724+
725+
expect(pinnedCells.length).toBe(unpinnedCells.length);
726+
727+
const headerCells = grid.headerCellList;
728+
expect(headerCells.filter(cell => cell.column.field === hiddenCol.field).length).toBe(0);
729+
730+
expect(grid.pinnedRows.length).toBe(1);
731+
const pinRowContainer = fix.debugElement.queryAll(By.css(FIXED_ROW_CONTAINER));
732+
expect(pinRowContainer.length).toBe(1);
733+
expect(pinRowContainer[0].children.length).toBe(1);
734+
expect(pinRowContainer[0].children[0].context.rowID).toBe(fix.componentInstance.data[1]);
735+
expect(pinRowContainer[0].children[0].nativeElement).toBe(grid.getRowByIndex(0).nativeElement);
736+
737+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[0]);
738+
expect(grid.getRowByIndex(2).rowID).toBe(fix.componentInstance.data[2]);
739+
740+
// 1 records pinned + 2px border
741+
expect(grid.pinnedRowHeight).toBe(grid.renderedRowHeight + 2);
742+
const expectedHeight = parseInt(grid.height, 10) - grid.pinnedRowHeight - 18 - grid.theadRow.nativeElement.offsetHeight;
743+
expect(grid.calcHeight - expectedHeight).toBeLessThanOrEqual(1);
744+
});
745+
});
702746
});
703747

704748
@Component({

src/app/grid-column-pinning/grid-column-pinning.sample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class GridColumnPinningSampleComponent implements OnInit {
103103

104104
togglePinRow(index) {
105105
const rec = this.data[index];
106-
this.grid1.isRecordPinned(rec) ?
106+
!this.grid1.isRecordPinned(rec) ?
107107
this.grid1.pinRow(rec) :
108108
this.grid1.unpinRow(rec)
109109
}

src/app/grid-row-pinning/grid-row-pinning.sample.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<igx-switch (change)='onRowChange()' style="padding-left: 10px"> Bottom Row Pinning toggle</igx-switch>
1010
<igx-switch (change)='onChange()' style="padding-left: 10px"> Right Column Pinning toggle</igx-switch>
1111
</div>
12-
<igx-grid [allowFiltering]='true' [primaryKey]='"ID"' [pinning]="pinningConfig" [showToolbar]='true' [columnPinning]='true' #grid1 [data]="data" [width]="'800px'" [height]="'500px'" [rowSelectable]="false">
12+
<igx-grid [allowFiltering]='true' [primaryKey]='"ID"' [pinning]="pinningConfig" [showToolbar]='true' [columnHiding]='true' [columnPinning]='true' #grid1 [data]="data" [width]="'800px'" [height]="'500px'" [rowSelectable]="false">
1313
<igx-column width='70px' [filterable]='false'>
1414
<ng-template igxCell let-cell="cell" let-val>
1515
<igx-icon class="pin-icon" (mousedown)="togglePining(cell.row, $event)">

0 commit comments

Comments
 (0)