Skip to content

Commit 418ba1d

Browse files
committed
chore(hGrid): address comments
1 parent fdf6c70 commit 418ba1d

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
@@ -13,7 +13,6 @@ import {
1313
NgZone,
1414
Optional,
1515
Output,
16-
QueryList,
1716
reflectComponentType,
1817
ViewContainerRef
1918
} from '@angular/core';
@@ -28,7 +27,7 @@ import { IgxHierarchicalGridNavigationService } from './hierarchical-grid-naviga
2827
import { IgxGridSummaryService } from '../summaries/grid-summary.service';
2928
import { IgxGridSelectionService } from '../selection/selection.service';
3029
import { IgxColumnResizingService } from '../resizing/resizing.service';
31-
import { ColumnType, GridType, IGX_GRID_SERVICE_BASE, IPathSegment } from '../common/grid.interface';
30+
import { GridType, IGX_GRID_SERVICE_BASE, IPathSegment } from '../common/grid.interface';
3231
import { IgxColumnGroupComponent } from '../columns/column-group.component';
3332
import { IgxColumnComponent } from '../columns/column.component';
3433
import { IForOfState } from '../../directives/for-of/for_of.directive';
@@ -211,7 +210,9 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
211210
this.columns.forEach(column => {
212211
if (column[output.propName]) {
213212
column[output.propName].pipe(takeUntil(column.destroy$)).subscribe((args) => {
214-
const rowIslandColumn = this.getRowIslandColumn(column, this.parentIsland.childColumns);
213+
const rowIslandColumn = this.parentIsland.columnList.find((col) => col.field
214+
? col.field === column.field
215+
: col.header === column.header);
215216
rowIslandColumn[output.propName].emit({ args, owner: this });
216217
});
217218
}
@@ -275,32 +276,6 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
275276
}
276277
return this.gridAPI.getChildGrid(path);
277278
}
278-
279-
private getRowIslandColumn(
280-
target: ColumnType,
281-
columns: QueryList<ColumnType>
282-
): ColumnType {
283-
const targetField = target.field ?? target.header;
284-
let result;
285-
286-
for (const col of columns) {
287-
const colField = col.field ?? col.header;
288-
289-
if (colField === targetField) {
290-
result = col;
291-
break;
292-
} else if (col.children) {
293-
const column = this.getRowIslandColumn(target, col.children);
294-
295-
if (column) {
296-
result = column;
297-
break;
298-
}
299-
}
300-
}
301-
302-
return result;
303-
}
304279
}
305280

306281
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)