Skip to content

Commit 5ec57a4

Browse files
committed
chore(hGrid): address comments
1 parent 2258654 commit 5ec57a4

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

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

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
NgZone,
1515
Optional,
1616
Output,
17-
QueryList,
1817
reflectComponentType,
1918
ViewContainerRef
2019
} from '@angular/core';
@@ -29,7 +28,7 @@ import { IgxHierarchicalGridNavigationService } from './hierarchical-grid-naviga
2928
import { IgxGridSummaryService } from '../summaries/grid-summary.service';
3029
import { IgxGridSelectionService } from '../selection/selection.service';
3130
import { IgxColumnResizingService } from '../resizing/resizing.service';
32-
import { ColumnType, GridType, IGX_GRID_SERVICE_BASE, IPathSegment } from '../common/grid.interface';
31+
import { GridType, IGX_GRID_SERVICE_BASE, IPathSegment } from '../common/grid.interface';
3332
import { IgxColumnGroupComponent } from '../columns/column-group.component';
3433
import { IgxColumnComponent } from '../columns/column.component';
3534
import { IForOfState } from '../../directives/for-of/for_of.directive';
@@ -212,7 +211,9 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
212211
this.columns.forEach(column => {
213212
if (column[output.propName]) {
214213
column[output.propName].pipe(takeUntil(column.destroy$)).subscribe((args) => {
215-
const rowIslandColumn = this.getRowIslandColumn(column, this.parentIsland.childColumns);
214+
const rowIslandColumn = this.parentIsland.columnList.find((col) => col.field
215+
? col.field === column.field
216+
: col.header === column.header);
216217
rowIslandColumn[output.propName].emit({ args, owner: this });
217218
});
218219
}
@@ -276,32 +277,6 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
276277
}
277278
return this.gridAPI.getChildGrid(path);
278279
}
279-
280-
private getRowIslandColumn(
281-
target: ColumnType,
282-
columns: QueryList<ColumnType>
283-
): ColumnType {
284-
const targetField = target.field ?? target.header;
285-
let result;
286-
287-
for (const col of columns) {
288-
const colField = col.field ?? col.header;
289-
290-
if (colField === targetField) {
291-
result = col;
292-
break;
293-
} else if (col.children) {
294-
const column = this.getRowIslandColumn(target, col.children);
295-
296-
if (column) {
297-
result = column;
298-
break;
299-
}
300-
}
301-
}
302-
303-
return result;
304-
}
305280
}
306281

307282
const flatten = (arr: any[]) => {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,23 +1731,25 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
17311731
const expandIcon = columnGroup2Header.queryAll(By.css('.igx-icon'))[0];
17321732
const pinIcon = columnGroup2Header.queryAll(By.css('.igx-icon'))[1];
17331733

1734-
expect(columnGroup2.expanded).toBeFalsy();
1735-
expect(columnGroup2.pinned).toBeFalsy();
1734+
expect(columnGroup2.expanded).toBeFalse();
1735+
expect(columnGroup2.pinned).toBeFalse();
17361736

17371737
UIInteractions.simulateClickEvent(expandIcon.nativeElement);
17381738
fixture.detectChanges();
17391739

1740-
expect(columnGroup2.expanded).toBeTruthy();
1740+
expect(columnGroup2.expanded).toBeTrue();
17411741

17421742
expect(fixture.componentInstance.expandedArgs).toBeDefined();
1743-
expect(fixture.componentInstance.expandedArgs).not.toBe(false);
1743+
expect(fixture.componentInstance.expandedArgs.args).toBeTrue();
17441744
expect(fixture.componentInstance.hiddenArgs).toBeDefined();
1745+
expect(fixture.componentInstance.hiddenArgs.args).toBeTrue();
17451746

17461747
UIInteractions.simulateClickEvent(pinIcon.nativeElement);
17471748
fixture.detectChanges();
17481749

1749-
expect(columnGroup2.pinned).toBeTruthy();
1750+
expect(columnGroup2.pinned).toBeTrue();
17501751
expect(fixture.componentInstance.pinnedArgs).toBeDefined();
1752+
expect(fixture.componentInstance.pinnedArgs.args).toBeTrue();
17511753
});
17521754
});
17531755
});

0 commit comments

Comments
 (0)