Help us shape the 2021 DevExtreme Roadmap. Take our 5 minute survey.
Your search did not match any results.
Data Grid

Batch Update Request

With the DevExtreme DataGrid, users can modify multiple records and submit all changes simultaneously (when editing.mode is set to "batch"). Batch editing allows you to optimize your app, address performance related issues, and deliver the best possible user experience across a variety of usage scenarios.

If data is stored on a server, our DataGrid sends multiple requests to save edited objects - one request per object (this is because most servers only process one edit operation at a time). If your server supports batch update, you can configure the DataGrid to save all changes with a single request.

To incorporate this functionality into your web app, implement the DataGrid's onSaving function. This function accepts an e object that contains fields used for batch update. The following is a summary of the steps you must follow to enable batch update:

  1. Disable default save logic
    Set the e.cancel field to true.

  2. Send pending changes to the server
    Pending changes are contained in the e.changes array. Ensure it is not empty and send the changes to the server.

  3. Update data in the widget
    Once changes are saved, call the refresh(changesOnly) method.

  4. Reset edit state
    Use the cancelEditData() method to clear pending changes.

Copy to CodeSandBox
<dx-data-grid id="gridContainer" [dataSource]="ordersStore" [showBorders]="true" [remoteOperations]="true" [repaintChangesOnly]="true" (onSaving)="onSaving($event)"> <dxo-editing mode="batch" [allowAdding]="true" [allowDeleting]="true" [allowUpdating]="true" ></dxo-editing> <dxi-column dataField="OrderID" [allowEditing]="false"></dxi-column> <dxi-column dataField="ShipName"></dxi-column> <dxi-column dataField="ShipCountry"></dxi-column> <dxi-column dataField="ShipCity"></dxi-column> <dxi-column dataField="ShipAddress"></dxi-column> <dxi-column dataField="OrderDate" dataType="date"></dxi-column> <dxi-column dataField="Freight"></dxi-column> </dx-data-grid>
import { NgModule, Component, enableProdMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { HttpClient, HttpClientModule } from '@angular/common/http'; import DxDataGrid from 'devextreme/ui/data_grid'; import { DxDataGridModule } from 'devextreme-angular'; import * as AspNetData from 'devextreme-aspnet-data-nojquery'; if (!/localhost/.test( { enableProdMode(); } const URL = ''; @Component({ selector: 'demo-app', templateUrl: 'app/app.component.html', styleUrls: ['app/app.component.css'] }) export class AppComponent { ordersStore: any; constructor(private http: HttpClient) { this.ordersStore = AspNetData.createStore({ key: 'OrderID', loadUrl: `${URL}/Orders`, onBeforeSend: function (method, ajaxOptions) { ajaxOptions.xhrFields = { withCredentials: true }; } }); } onSaving(e: any) { e.cancel = true; if (e.changes.length) { e.promise = this.processBatchRequest(`${URL}/Batch`, e.changes, e.component); } } async processBatchRequest(url: string, changes: Array<{}>, component: DxDataGrid): Promise<any> { await, JSON.stringify(changes), { withCredentials: true, headers: { 'Content-Type': 'application/json' } }).toPromise(); await component.refresh(true); component.cancelEditData(); } } @NgModule({ imports: [ BrowserModule, DxDataGridModule, HttpClientModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule);
::ng-deep #gridContainer { height: 440px; }
// In real applications, you should not transpile code in the browser. You can see how to create your own application with Angular and DevExtreme here: // System.config({ transpiler: 'ts', typescriptOptions: { module: "system", emitDecoratorMetadata: true, experimentalDecorators: true }, meta: { 'typescript': { "exports": "ts" }, 'devextreme-aspnet-data-nojquery': { "esModule": true }, 'devextreme/localization.js': { "esModule": true } }, paths: { 'npm:': '' }, map: { 'ts': 'npm:plugin-typescript@8.0.0/lib/plugin.js', 'typescript': 'npm:typescript@3.5.3/lib/typescript.js', '@angular': 'npm:@angular', 'tslib': 'npm:tslib@2.0.3/tslib.js', 'rxjs': 'npm:rxjs@6.3.3', 'devextreme-aspnet-data-nojquery': 'npm:devextreme-aspnet-data-nojquery@2.6.1/index.js', 'rrule': 'npm:rrule@2.6.6/dist/es5/rrule.js', 'luxon': 'npm:luxon@1.25.0/build/global/luxon.min.js', 'es6-object-assign': 'npm:es6-object-assign@1.1.0', 'devextreme': 'npm:devextreme@20.2.4', 'jszip': 'npm:jszip@3.5.0/dist/jszip.min.js', 'devextreme-quill': 'npm:devextreme-quill@0.9.7/dist/dx-quill.min.js', 'devexpress-diagram': 'npm:devexpress-diagram@2.0.5', 'devexpress-gantt': 'npm:devexpress-gantt@2.0.8', 'devextreme-angular': 'npm:devextreme-angular@20.2.4', 'preact': 'npm:preact@10.5.7/dist/preact.js', 'preact/hooks': 'npm:preact@10.5.7/hooks/dist/hooks.js' }, packages: { 'app': { main: './app.component.ts', defaultExtension: 'ts' }, 'devextreme': { defaultExtension: 'js' }, 'devextreme/events/utils': { main: 'index' }, 'devextreme/events': { main: 'index' }, 'es6-object-assign': { main: './index.js', defaultExtension: 'js' } }, packageConfigPaths: [ "npm:@angular/*/package.json", "npm:@angular/common/*/package.json", "npm:rxjs/package.json", "npm:rxjs/operators/package.json", "npm:devextreme-angular/*/package.json", "npm:devextreme-angular/ui/*/package.json", "npm:devextreme-angular/package.json", "npm:devexpress-diagram/package.json", "npm:devexpress-gantt/package.json", ] });
<!DOCTYPE html> <html xmlns=""> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <script src=""></script> <script src=""></script> <script src=""></script> <script src="config.js"></script> <script> System.import('app').catch(console.error.bind(console)); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> </body> </html>