React Lookup - OData Service
Use the ODataStore to bind the Lookup to data provided by an OData service.
jQuery
$(function() { $("#lookupContainer").dxLookup({ dataSource: new DevExpress.data.ODataStore({ url: "https://js.devexpress.com/Demos/DevAV/odata/Products", key: "Product_ID" }), valueExpr: "Product_Cost", displayExpr: "Product_Name" }); });
Angular
<dx-lookup [dataSource]="lookupDataSource" valueExpr="Product_Cost" displayExpr="Product_Name"> </dx-lookup>
import { DxLookupModule } from "devextreme-angular"; import ODataStore from "devextreme/data/odata/store"; // ... export class AppComponent { lookupDataSource = new ODataStore({ url: "https://js.devexpress.com/Demos/DevAV/odata/Products", key: "Product_ID" }); } @NgModule({ imports: [ // ... DxLookupModule ], // ... })
Vue
<template> <DxLookup :data-source="products" value-expr="Product_Cost" display-expr="Product_Name" /> </template> <script> import 'devextreme/dist/css/dx.light.css'; import { DxLookup } from 'devextreme-vue/lookup'; import ODataStore from "devextreme/data/odata/store"; export default { components: { DxLookup }, data() { return { products: new ODataStore({ url: "https://js.devexpress.com/Demos/DevAV/odata/Products", key: "Product_ID" }) }; } } </script>
React
import React from 'react'; 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.
jQuery
$(function() { $("#lookupContainer").dxLookup({ dataSource: new DevExpress.data.DataSource({ store: { type: "odata", url: "https://js.devexpress.com/Demos/DevAV/odata/Products", key: "Product_ID" }, filter: ["Product_Available", "=", true] }), valueExpr: "Product_Cost", displayExpr: "Product_Name" }); });
Angular
<dx-lookup [dataSource]="lookupDataSource" valueExpr="Product_Cost" displayExpr="Product_Name"> </dx-lookup>
import { DxLookupModule } from "devextreme-angular"; import DataSource from "devextreme/data/data_source"; import "devextreme/data/odata/store"; // ... export class AppComponent { lookupDataSource = new DataSource({ store: { type: "odata", url: "https://js.devexpress.com/Demos/DevAV/odata/Products", key: "Product_ID" }, filter: ["Product_Available", "=", true] }); } @NgModule({ imports: [ // ... DxLookupModule ], // ... })
Vue
<template> <DxLookup :data-source="products" value-expr="Product_Cost" display-expr="Product_Name" /> </template> <script> import 'devextreme/dist/css/dx.light.css'; import { DxLookup } from 'devextreme-vue/lookup'; import DataSource from "devextreme/data/data_source"; export default { components: { DxLookup }, data() { return { products: new DataSource({ store: { type: "odata", url: "https://js.devexpress.com/Demos/DevAV/odata/Products", key: "Product_ID" }, filter: ["Product_Available", "=", true] }) }; } } </script>
React
import React from 'react'; 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;
A 1-Click Solution for CRUD Web API Services with Role-based Access Control via EF Core
If you target .NET for your backend API, be sure to check out Web API Service and register your free copy today. The Solution Wizard scaffolds an OData v4 Web API Service (.NET 6+) with integrated authorization & CRUD operations powered by EF Core ORM. You can use OAuth2, JWT or custom authentication strategies alongside tools like Postman or Swagger (OpenAPI) for API testing. The built-in Web API Service also filters out secured server data based on permissions granted to users. Advanced/enterprise functions include audit trail, endpoints to download reports, file attachments, check validation, obtain localized captions, etc.
To use the free Solution Wizard (which creates the Web API Service), run the Universal Component Installer from the DevExpress Download Manager and use our predefined template in Visual Studio 2022+.
Read Tutorial | View Examples: JavaScript (DevExtreme) & JavaScript (Svelte) | Watch Videos
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.