DevExtreme React - OData
NOTE
This article describes how to bind a DevExtreme widget to an OData service in jQuery, Angular, Vue, and React. For information on data binding in ASP.NET MVC Controls, refer to docs.devexpress.com.
To access an OData service, implement the ODataStore: specify the url of an OData entity collection, the key property, and the OData version. You can also handle data-related events:
App.js
- import React from 'react';
- import 'devextreme/dist/css/dx.common.css';
- import 'devextreme/dist/css/dx.light.css';
- import DataGrid from 'devextreme-react/data-grid';
- import ODataStore from 'devextreme/data/odata/store';
- const productsStore = new ODataStore({
- url: 'https://js.devexpress.com/Demos/DevAV/odata/Products',
- key: 'Product_ID',
- version: 3,
- onLoaded: () => {
- // Event handling commands go here
- }
- });
- class App extends React.Component {
- render() {
- return (
- <DataGrid
- dataSource={productsStore}
- />
- );
- }
- }
- export default App;
Data from the ODataStore can be shaped (filtered, sorted, grouped, etc.) in the DataSource.
The following example declares an ODataStore, wraps it in a DataSource, and binds the DataGrid widget to this DataSource:
App.js
- import React from 'react';
- import 'devextreme/dist/css/dx.common.css';
- import 'devextreme/dist/css/dx.light.css';
- import DataGrid from 'devextreme-react/data-grid';
- import ODataStore from 'devextreme/data/odata/store';
- import DataSource from 'devextreme/data/data_source';
- const productsStore = new ODataStore({
- // ...
- });
- const productsDataSource = new DataSource({
- store: productsStore,
- sort: 'Product_Name'
- });
- class App extends React.Component {
- render() {
- return (
- <DataGrid
- dataSource={productsDataSource}
- />
- );
- }
- }
- export default App;
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.