Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
146318 | Jul 31,2019 07:33 AM UTC | Aug 2,2019 09:55 AM UTC | Angular - EJ 2 | 3 |
![]() |
Tags: TreeGrid |
<ejs-treegrid #treegrid [dataSource]='data' height='400' childMapping='subtasks' [treeColumnIndex]='0'[editSettings]='editSettings' (actionComplete)='actionComplete($event)'>
<e-columns>
<e-column field='taskID' headerText='Task ID' isPrimaryKey='true' width='90' textAlign='Right' ></e-column>
<e-column width="150">
<ng-template #template let-data>
<button (click)="insert(data)" *ngIf="data.level == 0">INSERT CHILD</button>
</ng-template>
</e-column>
</e-columns>
</ejs-treegrid>
export class AppComponent implements OnInit{
public data: Object[] = [];
public editSettings: Object;
@ViewChild('treegrid')
public treegrid: TreeGrid;
ngOnInit(): void {
this.data = sampleData;
this.editSettings ={ allowEditing: true, allowAdding: true, allowDeleting: true, mode:"Row", newRowPosition: 'Child'};
}
insert(data: any) {
var value = { taskID: 33333, taskName: 'Plan timeline'};
this.treegrid.addRecord(value, data.index);
// call addRecord method with data and index of parent record as parameters
}
|
actionComplete(args): void {
if (args.requestType == "save") {
var index = args.index;
this.treegrid.selectRow(index); // select the newly added row to scroll to it
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.