Tree Grid Batch Editing and Transactions

The Batch Editing feature of the IgxTreeGrid is based on the HierarchicalTransactionService. Follow the Transaction Service class hierarchy topic to see an overview of the igxHierarchicalTransactionService and details how it is implemented.

Below is a detailed example of how is Batch Editing enabled for the IgxTreeGrid component.


The following sample illustrates how to enable and use Batch Editing via Transaction as provider and has row editing enabled. The latter will ensure that transaction will be added after the entire row edit is confirmed. The sample uses a flat data source.


Transaction state consists of all the updated, added and deleted rows, and their last states.


To get started import the IgxTreeGridModule in the app.module.ts file:

// app.module.ts

import { IgxTreeGridModule } from 'igniteui-angular';

    imports: [..., IgxTreeGridModule],
export class AppModule {}

Then you need to define the igxTransactionService as a provider for the Tree Grid or for some of its parent components:

import { Component, ViewChild } from "@angular/core";
import { IgxGridComponent, IgxGridTransaction, IgxToggleDirective,
    IgxHierarchicalTransactionService, IgxTreeGridComponent } from "igniteui-angular";

    providers: [{ provide: IgxGridTransaction, useClass: IgxHierarchicalTransactionService }],
    selector: "app-tree-grid-batch-editing-sample",
    styleUrls: ["tree-grid-batch-editing-sample.component.scss"],
    templateUrl: "tree-grid-batch-editing-sample.component.html"
export class TreeGridBatchEditingSampleComponent { }

IgxGridTransaction is an injection token defined by the grid.

Then define a Tree Grid with bound data source and rowEditable set to true and bind:

<igx-tree-grid #treeGrid [data]="data" primaryKey="employeeID" foreignKey="PID" width ="100%" height ="500px" rowEditable=true rowSelectable=true columnHiding=true>
    <button igxButton (click)="addRow()">Add Root Level Row</button>
    <button igxButton [disabled]="!undoEnabled" (click)="undo()">Undo</button>
    <button igxButton [disabled]="!redoEnabled" (click)="redo()">Redo</button>
    <button igxButton [disabled]="!hasTransactions" (click)="openCommitDialog()">Commit</button>

The following code demonstrates the usage of the HierarchicalTransactionService API - undo, redo, commit.

export class TreeGridBatchEditingSampleComponent {
    @ViewChild("treeGrid", { read: IgxTreeGridComponent }) public treeGrid: IgxTreeGridComponent;
    public addRow() {
            PID: -1,
            Title: "Junior Sales Representative",
            employeeID: + this.nextRow++,
            firstName: "John",
            lastName: "Doe"

    public addChildRow(id) {
                Title: "Sales Manager",
                employeeID: + this.nextRow++,
                firstName: `Added `,
                lastName: "Added"

    public deleteRow(id) {

    public undo() {

    public redo() {

    public commit() {

    public cancel() {

    public discard() {

    public get undoEnabled(): boolean {
        return this.treeGrid.transactions.canUndo;

    public get redoEnabled(): boolean {
       return this.treeGrid.transactions.canRedo;

    public openCommitDialog() {;

    public get hasTransactions(): boolean {
        return this.treeGrid.transactions.getAggregatedChanges(false).length > 0;

Deleting a parent node in the grid has some peculiarities. If you are using a hierarchical data, the children will be deleted when deleting their parent. If you are using a flat data, you may set the desired behavior using the cascadeOnDelete property of the grid. This property indicates whether the child records should be deleted when their parent gets deleted (by default, it is set to true).


Disabling rowEditable property will modify Tree Grid to create transactions on cell change and will not expose row editing overlay in the UI.

API References

Additional Resources

Our community is active and always welcoming to new ideas.