Close
Angular React Web Components Blazor Blazor
Premium

Blazor Hierarchical Grid Batch Editing and Transactions

In order to use the HierarchicalTransactionService with IgbHierarchicalGrid, but have it accumulating separate transaction logs for each island, a service factory should be provided instead. One is exported and ready for use as HierarchicalTransactionServiceFactory.

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

Blazor Hierarchical Grid Batch Editing and Transactions Example

The following sample demonstrates a scenario, where the IgbHierarchicalGrid has IgbHierarchicalGrid.BatchEditing enabled and has row editing enabled. The latter will ensure that transaction will be added after the entire row edit is confirmed.

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

Usage

You need to enable IgbHierarchicalGrid.BatchEditing from your Hierarchical Grid:

<IgbHierarchicalGrid Data=data BatchEditing="true">
</IgbHierarchicalGrid>

This will ensure a proper instance of Transaction service is provided for the IgbHierarchicalGrid. The proper IgbTransactionService is provided through a TransactionFactory.

After batch editing is enabled, define a IgbHierarchicalGrid with bound data source and IgbHierarchicalGrid.RowEditable set to true and bind:

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

export class HierarchicalGridBatchEditingSampleComponent {
    public undo(grid: IgxHierarchicalGridComponent) {
        /* exit edit mode and commit changes */
        grid.endEdit(true);
        grid.transactions.undo();
    }

    public redo(grid: IgxHierarchicalGridComponent) {
        /* exit edit mode and commit changes */
        grid.endEdit(true);
        grid.transactions.redo();
    }

    public commit() {
        this.hierarchicalGrid.transactions.commit(this.data);
        this.childGrid.hgridAPI.getChildGrids().forEach((grid) => {
            grid.transactions.commit(grid.data);
        });
        this.dialogChanges.close();
    }
}

The transactions API won’t handle end of edit and you’d need to do it by yourself. Otherwise, IgbHierarchicalGrid would stay in edit mode. One way to do that is by calling EndEdit in the respective method.

Disabling IgbHierarchicalGrid.RowEditable property will modify IgbHierarchicalGrid 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.