|
App.component.html
<button id="button" (click)="addclick($event)">LOAD MORE</button>
<ejs-treeview
#treeviewComponent
id="default"
[fields]="field"
></ejs-treeview>
--------------------------------------
App.component.ts
export class AppComponent {
public hierarchicalData: Object[] = [
. . .
];
// Mapping TreeView fields property with data source properties
public field: Object = {
dataSource: this.hierarchicalData.slice(0, 3),
id: "id",
text: "name",
child: "subChild"
};
addclick() {
(this.treeviewComponent.fields as any) = {
dataSource: this.hierarchicalData,
id: "id",
text: "name",
child: "subChild"
}; }
} |
|
export class DefaultTreeViewComponent {
public onClick() {
let item: { [key: string]: Object } = {
id: this.count + "parent",
name: "New Folder" + this.count,
hasChildren: true,
subChild: [{ id: this.count + "child", name: "Folder" + this.count }]
};
this.tree.addNodes([item], this.tree.selectedNodes[0]);
++this.count;
}
} |