Skip to content

Commit 97429db

Browse files
authored
Merge branch 'master' into pbozhinov/fix-7615-10
2 parents 4e9b27d + 6621dd2 commit 97429db

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

projects/igniteui-angular/src/lib/grids/columns/column-layout.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ export class IgxColumnLayoutComponent extends IgxColumnGroupComponent implements
100100
this.children.forEach(child => child.hidden = value);
101101
if (this.grid && this.grid.columns && this.grid.columns.length > 0) {
102102
// reset indexes in case columns are hidden/shown runtime
103-
this.grid.columns.filter(x => x.columnGroup).forEach(x => x.populateVisibleIndexes());
103+
const columns = this.grid && this.grid.pinnedColumns && this.grid.unpinnedColumns ?
104+
this.grid.pinnedColumns.concat(this.grid.unpinnedColumns) : [];
105+
if (!this._hidden && !columns.find(c => c.field === this.field)) {
106+
this.grid.resetColumnCollections();
107+
}
108+
this.grid.columns.filter(x => x.columnLayout).forEach(x => x.populateVisibleIndexes());
104109
}
105110
}
106111

projects/igniteui-angular/src/lib/grids/grid/grid.multi-row-layout.integration.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,43 @@ describe('IgxGrid - multi-row-layout Integration #grid - ', () => {
143143
expect(grid.getColumnByName('ContactTitle').hidden).toBeTruthy();
144144
});
145145

146+
it('verify visible column indexes when hide/show a column', () => {
147+
148+
expect(grid.getColumnByName('ID').visibleIndex).toBe(0);
149+
expect(grid.getColumnByName('CompanyName').visibleIndex).toBe(1);
150+
expect(grid.getColumnByName('ContactName').visibleIndex).toBe(2);
151+
expect(grid.getColumnByName('ContactTitle').visibleIndex).toBe(3);
152+
// show PostalCode
153+
grid.getColumnByName('PostalCode').hidden = false;
154+
fixture.detectChanges();
155+
156+
expect(grid.getColumnByName('ID').visibleIndex).toBe(1);
157+
expect(grid.getColumnByName('CompanyName').visibleIndex).toBe(2);
158+
expect(grid.getColumnByName('ContactName').visibleIndex).toBe(3);
159+
expect(grid.getColumnByName('ContactTitle').visibleIndex).toBe(6);
160+
expect(grid.getColumnByName('PostalCode').visibleIndex).toBe(0);
161+
expect(grid.getColumnByName('City').visibleIndex).toBe(4);
162+
expect(grid.getColumnByName('Country').visibleIndex).toBe(5);
163+
expect(grid.getColumnByName('Address').visibleIndex).toBe(7);
164+
165+
// hide PostalCode
166+
grid.getColumnByName('PostalCode').hidden = true;
167+
fixture.detectChanges();
168+
expect(grid.getColumnByName('PostalCode').visibleIndex).toBe(-1);
169+
expect(grid.getColumnByName('City').visibleIndex).toBe(-1);
170+
expect(grid.getColumnByName('Country').visibleIndex).toBe(-1);
171+
expect(grid.getColumnByName('Address').visibleIndex).toBe(-1);
172+
173+
// show PostalCode
174+
grid.getColumnByName('PostalCode').hidden = false;
175+
fixture.detectChanges();
176+
expect(grid.getColumnByName('PostalCode').visibleIndex).toBe(0);
177+
expect(grid.getColumnByName('City').visibleIndex).toBe(4);
178+
expect(grid.getColumnByName('Country').visibleIndex).toBe(5);
179+
expect(grid.getColumnByName('Address').visibleIndex).toBe(7);
180+
});
181+
182+
146183
it('should work with horizontal virtualization when some groups are hidden/shown.', async() => {
147184
const uniqueGroups = [
148185
{

0 commit comments

Comments
 (0)