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
import React from 'react'; import 'devextreme/data/odata/store'; import { Column, DataGrid, FilterRow, HeaderFilter, GroupPanel, Scrolling, Editing, Grouping, Lookup, MasterDetail, Summary, RangeRule, RequiredRule, StringLengthRule, GroupItem, TotalItem, ValueFormat } from 'devextreme-react/data-grid'; import { createStore } from 'devextreme-aspnet-data-nojquery'; import MasterDetailGrid from './MasterDetailGrid.js'; const url = ''; 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 }; } }); class App extends React.Component { render() { return ( <DataGrid dataSource={dataSource} showBorders={true} height={600} remoteOperations={true} > <MasterDetail enabled={true} component={MasterDetailGrid} /> <FilterRow visible={true} /> <HeaderFilter visible={true} /> <GroupPanel visible={true} /> <Scrolling mode="virtual" /> <Editing mode="row" allowAdding={true} allowDeleting={true} allowUpdating={true} /> <Grouping autoExpandAll={false} /> <Column dataField="CustomerID" caption="Customer"> <Lookup dataSource={customersData} valueExpr="Value" displayExpr="Text" /> <StringLengthRule max={5} message="The field Customer must be a string with a maximum length of 5." /> </Column> <Column dataField="OrderDate" dataType="date"> <RequiredRule message="The OrderDate field is required." /> </Column> <Column dataField="Freight"> <HeaderFilter groupInterval={100} /> <RangeRule min={0} max={2000} message="The field Freight must be between 0 and 2000." /> </Column> <Column dataField="ShipCountry"> <StringLengthRule max={15} message="The field ShipCountry must be a string with a maximum length of 15." /> </Column> <Column dataField="ShipVia" caption="Shipping Company" dataType="number" > <Lookup dataSource={shippersData} valueExpr="Value" displayExpr="Text" /> </Column> <Summary> <TotalItem column="Freight" summaryType="sum"> <ValueFormat type="decimal" precision={2} /> </TotalItem> <GroupItem column="Freight" summaryType="sum"> <ValueFormat type="decimal" precision={2} /> </GroupItem> <GroupItem summaryType="count" /> </Summary> </DataGrid> ); } } export default App;
import React from 'react'; import DataGrid from 'devextreme-react/data-grid'; import { createStore } from 'devextreme-aspnet-data-nojquery'; const url = ''; class MasterDetailGrid extends React.Component { constructor(props) { super(props); this.dataSource = getMasterDetailGridDataSource(; } render() { return ( <DataGrid dataSource={this.dataSource} showBorders={true} /> ); } } function getMasterDetailGridDataSource(id) { return { store: createStore({ loadUrl: `${url}/OrderDetails`, loadParams: { orderID: id }, onBeforeSend: (method, ajaxOptions) => { ajaxOptions.xhrFields = { withCredentials: true }; } }) }; } export default MasterDetailGrid;
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.js'; ReactDOM.render( <App />, document.getElementById('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="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <script src=""></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"></div> </div> </body> </html>
System.config({ transpiler: 'plugin-babel', meta: { 'devextreme-aspnet-data-nojquery': { 'esModule': true }, }, paths: { 'npm:': '' }, defaultExtension: 'js', map: { 'react': 'npm:react@16.14.0/umd/react.development.js', 'react-dom': 'npm:react-dom@16.14.0/umd/react-dom.development.js', 'prop-types': 'npm:prop-types@15.7.2/prop-types.js', '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.3', 'devextreme-react': 'npm:devextreme-react@20.2.3', 'jszip': 'npm:jszip@3.5.0/dist/jszip.min.js', 'devextreme-quill': 'npm:devextreme-quill@0.9.5/dist/dx-quill.min.js', 'devexpress-diagram': 'npm:devexpress-diagram@2.0.0/dist/dx-diagram.js', 'devexpress-gantt': 'npm:devexpress-gantt@2.0.0/dist/dx-gantt.js', 'preact': 'npm:preact@10.5.5/dist/preact.js', 'preact/hooks': 'npm:preact@10.5.5/hooks/dist/hooks.js', // SystemJS plugins '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': { defaultExtension: 'js' }, 'devextreme-react': { main: 'index.js' }, 'devextreme/events/utils': { main: 'index' }, 'devextreme/events': { main: 'index' }, 'es6-object-assign': { main: './index.js', defaultExtension: 'js' } }, babelOptions: { sourceMaps: false, stage0: true, react: true } });