Skip to content

Commit 1bd817d

Browse files
MKirovaMKirova
authored andcommitted
feat(igxHierarchicalGrid): Allow binding row-island key property to complex object.
1 parent e22620e commit 1bd817d

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Inject, Pipe, PipeTransform } from '@angular/core';
2-
import { cloneArray } from '../../core/utils';
2+
import { cloneArray, resolveNestedPath } from '../../core/utils';
33
import { DataUtil } from '../../data-operations/data-util';
44
import { GridPagingMode } from '../common/enums';
55
import { GridType, IGX_GRID_BASE } from '../common/grid.interface';
@@ -41,7 +41,8 @@ export class IgxGridHierarchicalPipe implements PipeTransform {
4141
if (!v[childKey]) {
4242
v[childKey] = [];
4343
}
44-
const childData = v[childKey];
44+
const hasNestedPath = childKey?.includes('.');
45+
const childData = !hasNestedPath ? v[childKey] : resolveNestedPath(v, childKey);
4546
childGridsData[childKey] = childData;
4647
});
4748
if (grid.gridAPI.get_row_expansion_state(v)) {

src/app/hierarchical-grid/hierarchical-grid.sample.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h4 class="sample-title">Sample One</h4>
5555
<ng-template igxRowCollapsedIndicator>
5656
<igx-icon role="button">add</igx-icon>
5757
</ng-template>
58-
<igx-row-island [rowDraggable]="true" [height]='"400px"' [showExpandAll]='true' [key]="'childData'"
58+
<igx-row-island [rowDraggable]="true" [height]='"400px"' [showExpandAll]='true' [key]="'childData.Records'"
5959
[autoGenerate]="false" [allowFiltering]='true' [rowSelection]='selectionMode' [rowEditable]="true"
6060
[expandChildren]="firstLevelExpanded" #layout1 [allowFiltering]="true" filterMode="excelStyleFilter">
6161
<igx-grid-excel-style-filtering [minHeight]="'200px'" [maxHeight]="'360px'">
@@ -81,14 +81,14 @@ <h4 class="sample-title">Sample One</h4>
8181
Moving child {{data.ProductName}}!
8282
</div>
8383
</ng-template>
84-
<igx-row-island [key]="'childData'" [autoGenerate]="false" [rowSelection]='selectionMode' [batchEditing]="true" [rowEditable]="true"
84+
<igx-row-island [key]="'childData.Records'" [autoGenerate]="false" [rowSelection]='selectionMode' [batchEditing]="true" [rowEditable]="true"
8585
[allowFiltering]="true">
8686
<igx-column field="ID" [hasSummary]='true'></igx-column>
8787
<igx-column-group header="Information3">
8888
<igx-column [resizable]="true" field="ChildLevels"></igx-column>
8989
<igx-column field="ProductName"></igx-column>
9090
</igx-column-group>
91-
<igx-row-island [key]="'childData'" [autoGenerate]="false" [rowSelection]='selectionMode' [batchEditing]="true" [rowEditable]="true">
91+
<igx-row-island [key]="'childData.Records'" [autoGenerate]="false" [rowSelection]='selectionMode' [batchEditing]="true" [rowEditable]="true">
9292
<igx-column field="ID" [hasSummary]='true'></igx-column>
9393
<igx-column-group header="Information4">
9494
<igx-column field="ChildLevels"></igx-column>
@@ -126,7 +126,7 @@ <h4 class="sample-title">Sample two</h4>
126126
<button igxButton="raised" (click)='toggleRootLevel()'>Toggle root level</button>
127127
<button igxButton="raised" (click)='toggleFirstIsland()'>Toggle level 1</button>
128128
</div>
129-
<igx-hierarchical-grid [showExpandAll]='true' [primaryKey]="'ID'" [data]="localData" [autoGenerate]="true" [height]="'600px'"
129+
<!-- <igx-hierarchical-grid [showExpandAll]='true' [primaryKey]="'ID'" [data]="localData" [autoGenerate]="true" [height]="'600px'"
130130
[width]="'800px'" [rowEditable]="true" #hGrid2>
131131
<igx-row-island [key]="'childData'" [autoGenerate]="true" [rowSelection]='selectionMode' [batchEditing]="true" [rowEditable]="true"
132132
[allowFiltering]="true">
@@ -179,5 +179,5 @@ <h4 class="sample-title">Sample 4</h4>
179179
<igx-column field="ID" header='ID' [hasSummary]='true' [dataType]="'number'"></igx-column>
180180
<igx-column *ngFor="let c of childColumns" [field]="c"></igx-column>
181181
</igx-row-island>
182-
</igx-hierarchical-grid>
182+
</igx-hierarchical-grid> -->
183183
</div>

src/app/hierarchical-grid/hierarchical-grid.sample.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export class HierarchicalGridSampleComponent implements AfterViewInit {
4949
this.data1 = this.localData.slice(0, 10);
5050
this.data2 = this.localData.slice(10, 20);
5151
this.localData1 = this.data1;
52-
this.localData[0].hasChild = false;
53-
this.localData[1].hasChild = false;
54-
this.localData[2].childData[0].hasChild = false;
55-
this.localData[2].childData[1].hasChild = false;
52+
// this.localData[0].hasChild = false;
53+
// this.localData[1].hasChild = false;
54+
// this.localData[2].childData[0].hasChild = false;
55+
// this.localData[2].childData[1].hasChild = false;
5656
this.selectionMode = GridSelectionMode.none;
5757
}
5858

@@ -121,7 +121,9 @@ export class HierarchicalGridSampleComponent implements AfterViewInit {
121121
Col1: i,
122122
Col2: i,
123123
Col3: i,
124-
childData: children,
124+
childData: {
125+
Records: children
126+
},
125127
childData2: i % 2 ? [] : children,
126128
hasChild: true
127129
});

0 commit comments

Comments
 (0)