Skip to content

Commit 81a79fd

Browse files
committed
feat(tree-grid): change default expandedLevels; fix for pinned columns #2530
1 parent 562ffdc commit 81a79fd

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

Diff for: projects/igniteui-angular/src/lib/tree-grid/tree-cell.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class IgxTreeGridCellComponent extends IgxGridCellComponent {
3535
const indentationLevel = this.indentation;
3636
const expandedLevels = (<IgxTreeGridComponent>this.grid).expandedLevels;
3737

38-
return expandedLevels < 0 || (expandedLevels >= 0 && indentationLevel < expandedLevels);
38+
return indentationLevel < expandedLevels;
3939
}
4040

4141
public toggle() {

Diff for: projects/igniteui-angular/src/lib/tree-grid/tree-grid-row.component.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
</div>
88
</ng-container>
99
<ng-container *ngIf="pinnedColumns.length > 0">
10-
<igx-grid-cell *ngFor="let col of notGroups(pinnedColumns)" [column]="col" [row]="this" [style.min-width.px]="col.width" [style.flex-basis.px]="col.width" [value]="rowData[col.field]" [cellTemplate]="col.bodyTemplate"></igx-grid-cell>
10+
<ng-template ngFor let-col [ngForOf]="notGroups(pinnedColumns)">
11+
<ng-template #cellTemplate>
12+
<igx-grid-cell [column]="col" [row]="this" [style.min-width.px]="col.width" [style.flex-basis.px]="col.width" [value]="rowData[col.field]" [cellTemplate]="col.bodyTemplate" #treeCell></igx-grid-cell>
13+
</ng-template>
14+
<ng-template #treeCellTemplate>
15+
<igx-tree-grid-cell [column]="col" [row]="this" [style.min-width.px]="col.width" [style.flex-basis.px]="col.width" [value]="rowData[col.field]" [cellTemplate]="col.bodyTemplate" #treeCell></igx-tree-grid-cell>
16+
</ng-template>
17+
<ng-container *ngTemplateOutlet="col.visibleIndex === 0 ? treeCellTemplate : cellTemplate; context: getContext(col)"></ng-container>
18+
</ng-template>
1119
</ng-container>
1220
<ng-template igxFor let-col [igxForOf]="notGroups(unpinnedColumns)" [igxForScrollContainer]="grid.parentVirtDir" let-colIndex="index" [igxForScrollOrientation]="'horizontal'" [igxForContainerSize]='grid.unpinnedWidth' [igxForTrackBy]='grid.trackColumnChanges' #igxDirRef>
1321
<ng-template #cellTemplate>
@@ -16,5 +24,5 @@
1624
<ng-template #treeCellTemplate>
1725
<igx-tree-grid-cell [column]="col" [row]="this" [style.min-width.px]="col.width" [style.flex-basis.px]="col.width" [value]="rowData[col.field]" [cellTemplate]="col.bodyTemplate" #treeCell></igx-tree-grid-cell>
1826
</ng-template>
19-
<ng-container *ngTemplateOutlet="colIndex === 0 ? treeCellTemplate : cellTemplate; context: getContext(col)"></ng-container>
27+
<ng-container *ngTemplateOutlet="col.visibleIndex === 0 ? treeCellTemplate : cellTemplate; context: getContext(col)"></ng-container>
2028
</ng-template>

Diff for: projects/igniteui-angular/src/lib/tree-grid/tree-grid.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
8989
* @memberof IgxTreeGridRowComponent
9090
*/
9191
@Input()
92-
public expandedLevels = -1;
92+
public expandedLevels = Infinity;
9393

9494
private _expandedStates: Map<any, boolean> = new Map<any, boolean>();
9595

Diff for: projects/igniteui-angular/src/lib/tree-grid/tree-grid.pipes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class IgxTreeGridFlatteningPipe implements PipeTransform {
105105

106106
let isExpanded = expandedStates.get(rowID);
107107
if (isExpanded === undefined) {
108-
isExpanded = expandedLevels < 0 || (expandedLevels >= 0 && indentationLevel < expandedLevels);
108+
isExpanded = indentationLevel < expandedLevels;
109109
}
110110

111111
if (isExpanded) {

Diff for: src/app/tree-grid/tree-grid.sample.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
<div class="sample-content">
88
<div class="sample-column">
9-
<igx-tree-grid #grid1 [data]="data" childDataKey="ChildCompanies" expandedLevels="1" [rowSelectable]="true" [paging]="false" [width]="'900px'" [height]="'500px'">
9+
<igx-tree-grid #grid1 [data]="data" childDataKey="ChildCompanies" [rowSelectable]="true" [paging]="false" [width]="'900px'" [height]="'500px'">
1010
<igx-column *ngFor="let c of columns" [field]="c.field"
1111
[header]="c.field"
12+
[pinned]="c.pinned"
1213
[movable]="c.movable"
1314
[groupable]="false"
1415
[resizable]="c.resizable"

Diff for: src/app/tree-grid/tree-grid.sample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class TreeGridSampleComponent implements OnInit {
1818

1919
public ngOnInit(): void {
2020
this.columns = [
21-
{ field: 'ID', width: 150, resizable: true, movable: true },
21+
{ field: 'ID', width: 150, resizable: true, movable: true, pinned: true },
2222
{ field: 'CompanyName', width: 150, resizable: true, movable: true },
2323
{ field: 'ContactName', width: 150, resizable: true, movable: true },
2424
{ field: 'ContactTitle', width: 150, resizable: true, movable: true },

0 commit comments

Comments
 (0)