Batch editing in Angular TreeGrid component
12 Sep 202524 minutes to read
Batch editing is a feature in the TreeGrid component that enables editing of multiple cells simultaneously and allows all changes to be saved in a single request to the data source. This feature is useful for updating multiple cells at once, especially with large datasets that require efficient editing workflows.
In batch edit mode, double-clicking a TreeGrid cell puts it in editable state. Bulk updates (add, change, delete) can be saved by either clicking the toolbar’s Update button or programmatically calling the endEdit method.
To enable batch editing mode, set the editSettings.mode property to Batch.
Example to enable batch editing:
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { Component, OnInit } from '@angular/core';
import { projectData } from './datasource';
import { EditSettingsModel, ToolbarItems, EditService, ToolbarService, TreeGridModule } from '@syncfusion/ej2-angular-treegrid';
@Component({
imports: [ TreeGridModule ],
providers: [ EditService, ToolbarService,],
standalone: true,
selector: 'app-container',
template: `<ejs-treegrid [dataSource]='data' parentIdMapping='parentID' idMapping='TaskID' [toolbar]='toolbar' [treeColumnIndex]='1' height='270' [editSettings]='editSettings' >
<e-columns>
<e-column field='TaskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=180></e-column>
<e-column field='Priority' headerText='Priority' textAlign='Right' width=90></e-column>
<e-column field='StartDate' headerText='Start Date' textAlign='Right' format='yMd' type='date' editType='datepickeredit' width=90></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=80></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
public data?: Object[];
public editSettings?: EditSettingsModel;
public toolbar?: ToolbarItems[];
ngOnInit(): void {
this.data = projectData;
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch' };
this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Automatically update a column based on another column’s edited value
You can update the value of a column dynamically based on the edited value of another column in batch mode. This is achieved using the Cell Edit Template feature. In the example below, the price column is updated based on the units and unitPrice columns, and direct editing of the price column is prevented with the cellEdit event.
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { TreeGridModule } from '@syncfusion/ej2-angular-treegrid'
import { PageService, SortService, FilterService,EditService,ToolbarService } from '@syncfusion/ej2-angular-treegrid'
import {ButtonModule} from '@syncfusion/ej2-angular-buttons'
import { DropDownListAllModule } from '@syncfusion/ej2-angular-dropdowns'
import { Component, OnInit } from '@angular/core';
import { summaryData } from './datasource';
import { EditSettingsModel, ToolbarItems, TreeGridComponent } from '@syncfusion/ej2-angular-treegrid';
import { IEditCell } from '@syncfusion/ej2-angular-grids';
import { NumericTextBox } from '@syncfusion/ej2-inputs';
@Component({
imports: [ TreeGridModule, ButtonModule, DropDownListAllModule ],
providers: [PageService, EditService, ToolbarService],
standalone: true,
selector: 'app-container',
template: `<ejs-treegrid #treegrid id="treegrid" [dataSource]='data' [toolbar]='toolbarOptions' [treeColumnIndex]='1' height='270' [editSettings]='editSettings' childMapping='subtasks' (cellEdit)="cellEdit($event)">
<e-columns>
<e-column field='ID' headerText='ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='Name' headerText='Name' textAlign='Left' width=180></e-column>
<e-column field='units' headerText='Units' textAlign='Right' editType="numericedit" [edit]="unitsParams" format="C2" width=120></e-column>
<e-column field='unitPrice' headerText='Unit Price' textAlign='Right' editType="numericedit" [edit]="unitPriceParams" width=120></e-column>
<e-column field='price' headerText='Total Price' textAlign='Right' format="C2" width=110></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
@ViewChild('treegrid')
public treegrid?: TreeGridComponent;
public data?: Object[];
public editSettings?: EditSettingsModel;
public toolbarOptions?: ToolbarItems[];
public unitsParams?: IEditCell;
public unitPriceParams?: IEditCell;
public unitsElem?: HTMLElement;
public unitsObj?: NumericTextBox;
public unitPriceElem?: HTMLElement;
public unitPriceObj?: NumericTextBox;
ngOnInit(): void {
this.data = summaryData;
this.editSettings = {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
mode: 'Batch'
};
this.toolbarOptions = ['Add', 'Delete', 'Update', 'Cancel'];
this.unitsParams = {
create: () => {
this.unitsElem = document.createElement('input');
return this.unitsElem;
},
read: () => {
return (this.unitsObj as NumericTextBox).value;
},
destroy: () => {
(this.unitsObj as NumericTextBox).destroy();
},
write: (args: any) => {
var rowData = args.rowData;
var rowIndex :any = (this.treegrid as TreeGridComponent).getRowInfo(args.row).rowIndex;
this.unitsObj = new NumericTextBox({
value: args.rowData[args.column.field],
change: ((args: any) => {
var totalCostValue = args.value * rowData['unitPrice'];
(this.treegrid as TreeGridComponent).updateCell(rowIndex, 'price', totalCostValue);
}).bind(this)
});
this.unitsObj.appendTo(this.unitsElem);
}
};
this.unitPriceParams = {
create: () => {
this.unitPriceElem = document.createElement('input');
return this.unitPriceElem;
},
read: () => {
return (this.unitPriceObj as NumericTextBox).value;
},
destroy: () => {
(this.unitPriceObj as NumericTextBox).destroy();
},
write: (args: any) => {
var rowData = args.rowData;
var rowIndex = (this.treegrid as TreeGridComponent).getRowInfo(args.row).rowIndex;
this.unitPriceObj = new NumericTextBox({
value: args.rowData[args.column.field],
change: ((args: { value: number; }) => {
var totalCostValue = args.value * rowData['unitPrice'];
this.treegrid?.updateCell(rowIndex as number, 'price', totalCostValue);
}).bind(this)
});
this.unitPriceObj.appendTo(this.unitPriceElem);
}
};
}
cellEdit(args: any) {
if (args.columnName == 'price') {
args.cancel = true;
}
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Cancel edit based on a condition
The TreeGrid supports conditional cancelation of CRUD operations (Edit, Add, Delete) in batch edit mode. Use the cellEdit, beforeBatchAdd, and beforeBatchDelete events and set args.cancel to true to prevent editing, adding, or deleting based on custom logic. In the demo below, CRUD is prevented for rows where the Priority column value is Normal.
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { TreeGridModule } from '@syncfusion/ej2-angular-treegrid'
import { PageService, SortService, FilterService,EditService,ToolbarService } from '@syncfusion/ej2-angular-treegrid'
import { Component, OnInit } from '@angular/core';
import { projectData } from './datasource';
import { EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-angular-treegrid';
@Component({
imports: [ TreeGridModule ],
providers: [PageService, EditService, ToolbarService],
standalone: true,
selector: 'app-container',
template: `<ejs-treegrid [dataSource]='data' parentIdMapping='parentID' idMapping='TaskID' [toolbar]='toolbar' [treeColumnIndex]='1' height='270' [editSettings]='editSettings' (cellEdit)="cellEdit($event)" (beforeBatchAdd)="beforeBatchAdd($event)" (beforeBatchDelete)="beforeBatchDelete($event)" >
<e-columns>
<e-column field='TaskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=180></e-column>
<e-column field='Priority' headerText='Priority' textAlign='Right' width=120></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=110></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
public data?: object[];
public editSettings?: EditSettingsModel;
public toolbar?: ToolbarItems[];
public isAddable: boolean = true;
ngOnInit(): void {
this.data = projectData;
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch' };
this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
}
cellEdit(args: any) {
if (args.rowData['Priority'] == 'Normal') {
args.cancel = true;
}
}
beforeBatchAdd(args: any) {
if (!this.isAddable) {
args.cancel = true;
}
}
beforeBatchDelete(args: any) {
if (args.rowData['Priority'] == 'Normal') {
args.cancel = true;
}
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Confirmation dialog
A confirmation dialog appears before actions such as saving or canceling changes. This dialog can be enabled by setting showConfirmDialog in editSettings to true (default).
- The confirmation dialog requires editSettings.mode to be Batch.
- Setting
editSettings.showConfirmDialogto false disables the dialog in batch editing.- A separate dialog appears for delete actions.
Example to toggle the confirmation dialog:
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { TreeGridModule } from '@syncfusion/ej2-angular-treegrid'
import { PageService, EditService, ToolbarService } from '@syncfusion/ej2-angular-treegrid'
import { Component, OnInit } from '@angular/core';
import { projectData } from './datasource';
import { EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-angular-treegrid';
@Component({
imports: [TreeGridModule ],
providers: [PageService, EditService, ToolbarService],
standalone: true,
selector: 'app-container',
template: `<ejs-treegrid [dataSource]='data' parentIdMapping='parentID' idMapping='TaskID' [toolbar]='toolbar' [treeColumnIndex]='1' height='270' [editSettings]='editSettings' >
<e-columns>
<e-column field='TaskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=180></e-column>
<e-column field='Priority' headerText='Priority' textAlign='Right' width=90></e-column>
<e-column field='StartDate' headerText='Start Date' textAlign='Right' format='yMd' type='date' editType='datepickeredit' width=90></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=80></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
public data?: object[];
public editSettings?: EditSettingsModel;
public toolbar?: ToolbarItems[];
ngOnInit(): void {
this.data = projectData;
this.editSettings = {
showConfirmDialog: true, showDeleteConfirmDialog: true,
allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch'
};
this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Enable editing by single click and arrow keys
You can enable editing in a single click and navigate between cells or rows using arrow keys without having to double-click or use the mouse for navigation. By default, in batch mode, the TAB key can be used to edit or move to the next cell or row and the Enter key is used to move to the next row cell. However, you can customize this behavior to enable editing with a single click or using arrow keys.
To enable editing in a single click, you can handle the created event of the tree grid. Within the event handler, bind the click event to the tree grid cells and call the editCell method to make the clicked cell editable.
To enable editing using arrow keys, you can handle the load event of the TreeGrid component. Inside the event handler, you can bind the keydown event to the tree grid element and check for arrow key presses. Based on the arrow key pressed, you can identify the next or previous cell using the editCell method and make it editable.
Example for single-click editing and arrow key navigation:
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { TreeGridModule, TreeGridComponent } from '@syncfusion/ej2-angular-treegrid'
import { PageService, EditService, ToolbarService } from '@syncfusion/ej2-angular-treegrid'
import { Component, OnInit } from '@angular/core';
import { projectData } from './datasource';
import { EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-angular-treegrid';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
@Component({
imports: [TreeGridModule],
providers: [PageService, EditService, ToolbarService],
standalone: true,
selector: 'app-container',
template: `<ejs-treegrid #treegrid [dataSource]='data' parentIdMapping='parentID' idMapping='TaskID' [toolbar]='toolbar' [treeColumnIndex]='1' height='270' [editSettings]='editSettings' (created)="created()" (load)="load()" >
<e-columns>
<e-column field='TaskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=180></e-column>
<e-column field='Priority' headerText='Priority' textAlign='Right' width=90></e-column>
<e-column field='StartDate' headerText='Start Date' textAlign='Right' format='yMd' type='date' editType='datepickeredit' width=90></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=80></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
public data?: object[];
public editSettings?: EditSettingsModel;
public toolbar?: ToolbarItems[];
@ViewChild('treegrid')
public treegrid?: TreeGridComponent;
ngOnInit(): void {
this.data = projectData;
this.editSettings = {
showConfirmDialog: true, showDeleteConfirmDialog: true,
allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch'
};
this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
}
created = () => {
(this.treegrid as TreeGridComponent).getContentTable().addEventListener('click', (args) => {
if ((args.target as HTMLElement).classList.contains('e-rowcell') || (args.target as HTMLElement).classList.contains('e-treecell')) {
setTimeout(()=>{
(this.treegrid as TreeGridComponent).editModule.editCell(parseInt(((args.target as any).closest('.e-rowcell').getAttribute('index') as string)),
(this.treegrid as TreeGridComponent).grid.getColumnByIndex(parseInt((args.target as any).closest('.e-rowcell').getAttribute('data-colindex') as string)).field);
});
}
});
};
load = () => {
(this.treegrid as TreeGridComponent).element.addEventListener('keydown', (e) => {
var closesttd = (e.target as HTMLElement).closest('td');
if (e.keyCode === 39 && !isNullOrUndefined(((closesttd as HTMLTableCellElement).nextSibling as HTMLElement))) {
this.edit_Cell(((closesttd as HTMLTableCellElement).nextSibling as HTMLElement));
}
if (e.keyCode === 37 && !isNullOrUndefined(((closesttd as HTMLTableCellElement).previousSibling as HTMLElement)) &&
!(this.treegrid as TreeGridComponent).grid.getColumnByIndex(
parseInt((((closesttd as HTMLTableCellElement).previousSibling as HTMLElement).getAttribute('data-colindex') as string))).isPrimaryKey)
{
this.edit_Cell(((closesttd as HTMLTableCellElement).previousSibling as HTMLElement));
}
if (e.keyCode === 40 && !isNullOrUndefined((((closesttd as HTMLTableCellElement).closest('tr') as HTMLTableRowElement).nextSibling as HTMLElement ))) {
this.edit_Cell(
(((closesttd as HTMLTableCellElement).closest('tr') as HTMLTableRowElement).nextSibling as HTMLElement).querySelectorAll('td')[
parseInt(((closesttd as HTMLTableCellElement).getAttribute('data-colindex') as string))]);
}
if ( e.keyCode === 38 && !isNullOrUndefined((((closesttd as HTMLTableCellElement ).closest('tr') as HTMLTableRowElement).previousSibling as ChildNode))) {
this.edit_Cell(
(((closesttd as HTMLTableCellElement).closest('tr') as HTMLTableRowElement).previousSibling as HTMLElement).querySelectorAll('td')[
parseInt(((closesttd as HTMLTableCellElement).getAttribute('data-colindex') as string))]);
}
});
};
public edit_Cell(args: HTMLElement) {
(this.treegrid as TreeGridComponent).editModule.editCell(
parseInt((args.getAttribute('index') as string)),
(this.treegrid as TreeGridComponent).grid.getColumnByIndex(parseInt(args.getAttribute('data-colindex') as string)).field);
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Disable editing for specific cells
To prevent editing for certain cells (for example, cells with the value Normal), use the cellEdit event and set args.cancel to true.
Example for disabling editing for specific values:
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { TreeGridModule, TreeGridComponent } from '@syncfusion/ej2-angular-treegrid'
import { PageService, EditService, ToolbarService } from '@syncfusion/ej2-angular-treegrid'
import { Component, OnInit } from '@angular/core';
import { projectData } from './datasource';
import { EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-angular-treegrid';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
import { CellEditArgs } from '@syncfusion/ej2-angular-grids';
@Component({
imports: [TreeGridModule],
providers: [PageService, EditService, ToolbarService],
standalone: true,
selector: 'app-container',
template: `<ejs-treegrid #treegrid [dataSource]='data' parentIdMapping='parentID' idMapping='TaskID' [toolbar]='toolbar' [treeColumnIndex]='1' height='270' [editSettings]='editSettings' (cellEdit)="cellEdit($event)" >
<e-columns>
<e-column field='TaskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=180></e-column>
<e-column field='Priority' headerText='Priority' textAlign='Right' width=90></e-column>
<e-column field='StartDate' headerText='Start Date' textAlign='Right' format='yMd' type='date' editType='datepickeredit' width=90></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=80></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
public data?: object[];
public editSettings?: EditSettingsModel;
public toolbar?: ToolbarItems[];
@ViewChild('treegrid')
public treegrid?: TreeGridComponent;
ngOnInit(): void {
this.data = projectData;
this.editSettings = {
showConfirmDialog: true, showDeleteConfirmDialog: true,
allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch'
};
this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
}
cellEdit(args: CellEditArgs) {
if (args.value === 'Normal') {
args.cancel = true;
}
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Immediate save/update in batch mode
You can save changes immediately in batch mode using the cellSaved event and endEdit method.
- To skip the confirmation dialog with
endEdit, seteditSettings.showConfirmDialogto false. This requireseditSettings.modeto be Batch.
Example to save or update changes immediately:
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { TreeGridModule, TreeGridComponent } from '@syncfusion/ej2-angular-treegrid'
import { PageService, EditService, ToolbarService } from '@syncfusion/ej2-angular-treegrid'
import { Component, OnInit } from '@angular/core';
import { projectData } from './datasource';
import { EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-angular-treegrid';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
import { CellEditArgs, CellSaveArgs } from '@syncfusion/ej2-angular-grids';
@Component({
imports: [TreeGridModule],
providers: [PageService, EditService, ToolbarService],
standalone: true,
selector: 'app-container',
template: `<ejs-treegrid #treegrid [dataSource]='data' parentIdMapping='parentID' idMapping='TaskID' [toolbar]='toolbar' [treeColumnIndex]='1' height='270' [editSettings]='editSettings' (cellSaved)="save($event)" >
<e-columns>
<e-column field='TaskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=180></e-column>
<e-column field='Priority' headerText='Priority' textAlign='Right' width=90></e-column>
<e-column field='StartDate' headerText='Start Date' textAlign='Right' format='yMd' type='date' editType='datepickeredit' width=90></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=80></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
public data?: object[];
public editSettings?: EditSettingsModel;
public toolbar?: ToolbarItems[];
@ViewChild('treegrid')
public treegrid?: TreeGridComponent;
ngOnInit(): void {
this.data = projectData;
this.editSettings = {
showConfirmDialog: true, showDeleteConfirmDialog: true,
allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch'
};
this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
}
save(args: CellSaveArgs) {
(this.treegrid as TreeGridComponent).endEdit();
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Save all batch changes programmatically
You can trigger saving of changes using the endEdit method, such as from an external button.
Example for programmatic save:
import { NgModule,ViewChild } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { TreeGridModule, TreeGridComponent } from '@syncfusion/ej2-angular-treegrid'
import { ButtonModule, } from '@syncfusion/ej2-angular-buttons'
import { PageService, EditService, ToolbarService } from '@syncfusion/ej2-angular-treegrid'
import { Component, OnInit } from '@angular/core';
import { projectData } from './datasource';
import { EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-angular-treegrid';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
import { CellEditArgs, CellSaveArgs } from '@syncfusion/ej2-angular-grids';
@Component({
imports: [TreeGridModule, ButtonModule,],
providers: [PageService, EditService, ToolbarService],
standalone: true,
selector: 'app-container',
template: `<button ejs-button #button1 cssClass="btn btn-default" content="Update" id="update" (click)="onClicked()" ></button>
<ejs-treegrid #treegrid [dataSource]='data' parentIdMapping='parentID' idMapping='TaskID' [toolbar]='toolbar' [treeColumnIndex]='1' height='270' [editSettings]='editSettings'>
<e-columns>
<e-column field='TaskID' headerText='Task ID' [isPrimaryKey]='true' textAlign='Right' width=90></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=180></e-column>
<e-column field='Priority' headerText='Priority' textAlign='Right' width=90></e-column>
<e-column field='StartDate' headerText='Start Date' textAlign='Right' format='yMd' type='date' editType='datepickeredit' width=90></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=80></e-column>
</e-columns>
</ejs-treegrid>`
})
export class AppComponent implements OnInit {
public data?: object[];
public editSettings?: EditSettingsModel;
public toolbar?: ToolbarItems[];
@ViewChild('treegrid')
public treegrid?: TreeGridComponent;
ngOnInit(): void {
this.data = projectData;
this.editSettings = {
showConfirmDialog: true, showDeleteConfirmDialog: true,
allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch'
};
this.toolbar = ['Add', 'Edit', 'Delete', 'Cancel'];
}
onClicked(): void {
(this.treegrid as TreeGridComponent).endEdit();
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));