Skip to content

Commit

Permalink
Fixed #10137 - Header and Footer template for Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Apr 20, 2021
1 parent ade949c commit 4c1aa98
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/app/components/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ export class UITreeNode implements OnInit {
<div class="p-tree-loading-overlay p-component-overlay" *ngIf="loading">
<i [class]="'p-tree-loading-icon pi-spin ' + loadingIcon"></i>
</div>
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
<div *ngIf="filter" class="p-tree-filter-container">
<input #filter type="text" autocomplete="off" class="p-tree-filter p-inputtext p-component" [attr.placeholder]="filterPlaceholder"
(keydown.enter)="$event.preventDefault()" (input)="_filter($event)">
Expand All @@ -539,15 +540,18 @@ export class UITreeNode implements OnInit {
</cdk-virtual-scroll-viewport>
</ng-template>
<div class="p-tree-empty-message" *ngIf="!loading && (value == null || value.length === 0)">{{emptyMessage}}</div>
<ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
</div>
<div [ngClass]="{'p-tree p-tree-horizontal p-component':true,'p-tree-selectable':selectionMode}" [ngStyle]="style" [class]="styleClass" *ngIf="horizontal">
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
<div class="p-tree-loading-mask p-component-overlay" *ngIf="loading">
<i [class]="'p-tree-loading-icon pi-spin ' + loadingIcon"></i>
</div>
<table *ngIf="value&&value[0]">
<p-treeNode [node]="value[0]" [root]="true"></p-treeNode>
</table>
<div class="p-tree-empty-message" *ngIf="!loading && (value == null || value.length === 0)">{{emptyMessage}}</div>
<ng-container *ngTemplateOutlet="footerTemplate"></ng-container>
</div>
`,
changeDetection: ChangeDetectionStrategy.Default,
Expand Down Expand Up @@ -642,6 +646,10 @@ export class Tree implements OnInit,AfterContentInit,OnChanges,OnDestroy,Blockab

serializedValue: any[];

headerTemplate: TemplateRef<any>;

footerTemplate: TemplateRef<any>;

public templateMap: any;

public nodeTouched: boolean;
Expand Down Expand Up @@ -709,7 +717,19 @@ export class Tree implements OnInit,AfterContentInit,OnChanges,OnDestroy,Blockab
}

this.templates.forEach((item) => {
this.templateMap[item.name] = item.template;
switch (item.getType()) {
case 'header':
this.headerTemplate = item.template;
break;

case 'footer':
this.footerTemplate = item.template;
break;

default:
this.templateMap[item.name] = item.template;
break;
}
});
}

Expand Down

0 comments on commit 4c1aa98

Please sign in to comment.