Your search did not match any results.
Data Grid

Web API Service

To access a Web API service from the client, use the createStore method which is part of the DevExtreme.AspNet.Data extension. This extension also allows you to process data for DevExtreme widgets on the server. The server-side implementation is available under the DataGridWebApiController.cs tab in the ASP.NET MVC version of this demo.

To notify the DataGrid that data is processed on the server, set the remoteOperations option to true.

Copy to CodePen
Apply
Reset
var DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', function DemoController($scope) { var url = "https://js.devexpress.com/Demos/Mvc/api/DataGridWebApi"; $scope.gridOptions = { dataSource: DevExpress.data.AspNet.createStore({ key: "OrderID", loadUrl: url + "/Orders", insertUrl: url + "/InsertOrder", updateUrl: url + "/UpdateOrder", deleteUrl: url + "/DeleteOrder", onBeforeSend: function(method, ajaxOptions) { ajaxOptions.xhrFields = { withCredentials: true }; } }), remoteOperations: true, columns: [{ dataField: "CustomerID", caption: "Customer", validationRules: [{ type: "stringLength", message: "The field Customer must be a string with a maximum length of 5.", max: 5 }], lookup: { dataSource: DevExpress.data.AspNet.createStore({ key: "Value", loadUrl: url + "/CustomersLookup", onBeforeSend: function(method, ajaxOptions) { ajaxOptions.xhrFields = { withCredentials: true }; } }), valueExpr: "Value", displayExpr: "Text" } }, { dataField: "OrderDate", dataType: "date", validationRules: [{ type: "required", message: "The OrderDate field is required." }] }, { dataField: "Freight", headerFilter: { groupInterval: 100 }, validationRules: [{ type: "range", message: "The field Freight must be between 0 and 2000.", min: 0, max: 2000 }] }, { dataField: "ShipCountry", validationRules: [{ type: "stringLength", message: "The field ShipCountry must be a string with a maximum length of 15.", max: 15 }] }, { dataField: "ShipVia", caption: "Shipping Company", dataType: "number", lookup: { dataSource: DevExpress.data.AspNet.createStore({ key: "Value", loadUrl: url + "/ShippersLookup", onBeforeSend: function(method, ajaxOptions) { ajaxOptions.xhrFields = { withCredentials: true }; } }), valueExpr: "Value", displayExpr: "Text" } } ], filterRow: { visible: true }, headerFilter: { visible: true }, groupPanel: { visible: true }, scrolling: { mode: "virtual" }, height: 600, showBorders: true, masterDetail: { enabled: true, template: "detail" }, editing: { allowAdding: true, allowUpdating: true, allowDeleting: true }, grouping: { autoExpandAll: false }, summary: { totalItems: [{ column: "Freight", summaryType: "sum" }], groupItems: [{ column: "Freight", summaryType: "sum" }, { summaryType: "count" } ] } }; $scope.getMasterDetailGridSettings = function(order) { return { dataSource: DevExpress.data.AspNet.createStore({ loadUrl: url + '/OrderDetails', loadParams: { orderID : order.OrderID }, onBeforeSend: function(method, ajaxOptions) { ajaxOptions.xhrFields = { withCredentials: true }; } }), showBorders: true }; }; });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" > <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" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.1.8/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.1.8/css/dx.light.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C\/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/20.1.8/js/dx.all.js"></script> <script src="https://unpkg.com/devextreme-aspnet-data@2.6.1/js/dx.aspnet.data.js"></script> <script src="index.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body class="dx-viewport"> <div class="demo-container" ng-app="DemoApp" ng-controller="DemoController"> <div dx-data-grid="gridOptions" dx-item-alias="order"> <div data-options="dxTemplate: {name: 'detail'}"> <div dx-data-grid="getMasterDetailGridSettings(order.data)"></div> </div> </div> </body> </html>