React Lookup - OData Service

Use the ODataStore to bind the Lookup to data provided by an OData service.

  • import React from 'react';
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { Lookup } from 'devextreme-react/lookup';
  • import ODataStore from "devextreme/data/odata/store";
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.products = new ODataStore({
  • url: "https://js.devexpress.com/Demos/DevAV/odata/Products",
  • key: "Product_ID"
  • });
  • }
  •  
  • render() {
  • return (
  • <Lookup
  • dataSource={this.products}
  • valueExpr="Product_Cost"
  • displayExpr="Product_Name"
  • />
  • );
  • }
  • }
  •  
  • export default App;

Data kept in the ODataStore can be processed in a DataSource. For example, the DataSource can filter data.

  • import React from 'react';
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { Lookup } from 'devextreme-react/lookup';
  • import DataSource from "devextreme/data/data_source";
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.products = new DataSource({
  • store: {
  • type: "odata",
  • url: "https://js.devexpress.com/Demos/DevAV/odata/Products",
  • key: "Product_ID"
  • },
  • filter: ["Product_Available", "=", true]
  • });
  • }
  •  
  • render() {
  • return (
  • <Lookup
  • dataSource={this.products}
  • valueExpr="Product_Cost"
  • displayExpr="Product_Name"
  • />
  • );
  • }
  • }
  •  
  • export default App;
See Also