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 CodeSandBox
Apply
Reset
<template> <DxDataGrid :show-borders="true" :data-source="dataSource" :remote-operations="true" :height="600" > <DxColumn data-field="CustomerID" caption="Customer" > <DxLookup :data-source="customersData" value-expr="Value" display-expr="Text" /> <DxStringLengthRule :max="5" message="The field Customer must be a string with a maximum length of 5." /> </DxColumn> <DxColumn data-field="OrderDate" data-type="date" > <DxRequiredRule message="The OrderDate field is required."/> </DxColumn> <DxColumn data-field="Freight"> <DxHeaderFilter :group-interval="100"/> <DxRangeRule :min="0" :max="2000" message="The field Freight must be between 0 and 2000." /> </DxColumn> <DxColumn data-field="ShipCountry"> <DxStringLengthRule :max="15" message="The field ShipCountry must be a string with a maximum length of 15." /> </DxColumn> <DxColumn data-field="ShipVia" caption="Shipping Company" data-type="number" > <DxLookup :data-source="shippersData" value-expr="Value" display-expr="Text" /> </DxColumn> <DxMasterDetail :enabled="true" template="masterDetailTemplate" /> <template #masterDetailTemplate="{ data: order }"> <MasterDetailGrid :id="order.key" :url="url" /> </template> <DxFilterRow :visible="true"/> <DxHeaderFilter :visible="true"/> <DxGroupPanel :visible="true"/> <DxScrolling mode="virtual"/> <DxEditing :allow-adding="true" :allow-updating="true" :allow-deleting="true" mode="row" /> <DxGrouping :auto-expand-all="false"/> <DxSummary> <DxTotalItem column="Freight" summary-type="sum" > <DxValueFormat :precision="2" type="decimal" /> </DxTotalItem> <DxGroupItem column="Freight" summary-type="sum" > <DxValueFormat :precision="2" type="decimal" /> </DxGroupItem> <DxGroupItem summary-type="count"/> </DxSummary> </DxDataGrid> </template> <script> import { DxDataGrid, DxColumn, DxEditing, DxFilterRow, DxHeaderFilter, DxGroupPanel, DxGrouping, DxScrolling, DxSummary, DxLookup, DxTotalItem, DxGroupItem, DxMasterDetail, DxStringLengthRule, DxRequiredRule, DxRangeRule, DxValueFormat } from 'devextreme-vue/data-grid'; import MasterDetailGrid from './MasterDetailGrid.vue'; import { createStore } from 'devextreme-aspnet-data-nojquery'; const url = 'https://js.devexpress.com/Demos/Mvc/api/DataGridWebApi'; const dataSource = createStore({ key: 'OrderID', loadUrl: `${url}/Orders`, insertUrl: `${url}/InsertOrder`, updateUrl: `${url}/UpdateOrder`, deleteUrl: `${url}/DeleteOrder`, onBeforeSend: (method, ajaxOptions) => { ajaxOptions.xhrFields = { withCredentials: true }; } }); const customersData = createStore({ key: 'Value', loadUrl: `${url}/CustomersLookup`, onBeforeSend: (method, ajaxOptions) => { ajaxOptions.xhrFields = { withCredentials: true }; } }); const shippersData = createStore({ key: 'Value', loadUrl: `${url}/ShippersLookup`, onBeforeSend: (method, ajaxOptions) => { ajaxOptions.xhrFields = { withCredentials: true }; } }); export default { components: { DxDataGrid, DxColumn, DxEditing, DxFilterRow, DxHeaderFilter, DxGroupPanel, DxGrouping, DxScrolling, DxSummary, DxLookup, DxTotalItem, DxGroupItem, DxMasterDetail, DxStringLengthRule, DxRangeRule, DxRequiredRule, DxValueFormat, MasterDetailGrid }, data() { return { url, customersData, shippersData, dataSource }; } }; </script>
<template> <DxDataGrid :data-source="dataSource" :show-borders="true" /> </template> <script> import DxDataGrid from 'devextreme-vue/data-grid'; import { createStore } from 'devextreme-aspnet-data-nojquery'; const getMasterDetailGridDataSource = (id, url) => { return { store: createStore({ loadUrl: `${url}/OrderDetails`, loadParams: { orderID: id }, onBeforeSend: (method, ajaxOptions) => { ajaxOptions.xhrFields = { withCredentials: true }; } }) }; }; export default { components: { DxDataGrid }, props: { id: { type: Number, default: () => 0 }, url: { type: String, default: () => '' } }, data() { return { dataSource: getMasterDetailGridDataSource(this.id, this.url) }; } }; </script>
import { createApp } from 'vue'; import App from './App.vue'; createApp(App).mount('#app');
<!DOCTYPE html> <html> <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="https://cdn3.devexpress.com/jslib/20.2.4/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.4/css/dx.light.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"/> </div> </body> </html>
System.config({ transpiler: 'plugin-babel', meta: { '*.vue': { loader: 'vue-loader' }, 'devextreme-aspnet-data-nojquery': { 'esModule': true }, }, paths: { 'npm:': 'https://unpkg.com/' }, map: { 'vue': 'npm:vue@3.0.0/dist/vue.esm-browser.js', 'vue-loader': 'npm:dx-systemjs-vue-browser@1.0.15/index.js', 'devextreme-aspnet-data-nojquery': 'npm:devextreme-aspnet-data-nojquery@2.6.1/index.js', 'mitt': 'npm:mitt/dist/mitt.umd.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', 'devextreme-vue': 'npm:devextreme-vue@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/dist/dx-diagram.js', 'devexpress-gantt': 'npm:devexpress-gantt@2.0.8/dist/dx-gantt.js', 'preact': 'npm:preact@10.5.7/dist/preact.js', 'preact/hooks': 'npm:preact@10.5.7/hooks/dist/hooks.js', 'plugin-babel': 'npm:systemjs-plugin-babel@0.0.25/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js' }, packages: { 'devextreme-vue': { main: 'index.js' }, 'devextreme': { defaultExtension: 'js' }, 'devextreme/events/utils': { main: 'index' }, 'devextreme/events': { main: 'index' }, 'es6-object-assign': { main: './index.js', defaultExtension: 'js' } }, babelOptions: { sourceMaps: false, stage0: true } });