Skip to content

Commit

Permalink
feat: support expand and collapse groups
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerkay committed Jun 28, 2020
1 parent c57bb59 commit 2072aac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions example/src/app/gantt/gantt.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
<input type="checkbox" [(ngModel)]="options.linkable" />
</span>
</div>

<div class="header-section">
<span class="header-section-content">
<button (click)="gantt.expandAll()">全部展开</button>
</span>
</div>
<div class="header-section">
<span class="header-section-content">
<button (click)="gantt.collapseAll()">全部收起</button>
</span>
</div>
</div>
<div class="gantt-demo-content">
<ngx-gantt
Expand Down
18 changes: 18 additions & 0 deletions packages/gantt/src/gantt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,22 @@ export class NgxGanttComponent extends GanttUpper implements GanttRef, OnInit, A
ngOnDestroy() {
super.onDestroy();
}

private expandGroups(expanded: boolean) {
this.groups.forEach((group) => {
group.setExpand(expanded);
});
this.expandChange.next();
this.cdr.detectChanges();
}

// public functions

expandAll() {
this.expandGroups(true);
}

collapseAll() {
this.expandGroups(false);
}
}

0 comments on commit 2072aac

Please sign in to comment.