UI Widgets Lookup

A widget that allows a user to select predefined values from a lookup window.

Type: Object

The dxLookup widget allows users to select predefined values from a lookup window. To create the dxLookup widget, add a div element with dxLookup Knockout binding within the body of the required view.

<div data-bind="dxLookup:{dataSource: employees, displayExpr: 'name', valueExpr: 'id'}"></div>

The lookup items are loaded from an array specified via the dataSource configuration option. You can specify a simple array or an array of objects as the widget data source.

var employees = [
    { id:1, name: "Bob", hired: 2005 },
    { id:2, name: "John", hired: 2007 },
    { id:3, name: "Frank", hired: 2001 },
    { id:4, name: "Robert", hired: 2007 },
    { id:5, name: "Paul", hired: 2011 },
    { id:6, name: "Elizabeth", hired: 2000 },
    { id:7, name: "Mary", hired: 2002 },
    { id:8, name: "Michael", hired: 2003 },
    { id:9, name: "George", hired: 2002 },
    { id:10, name: "Deborah", hired: 2000 },
    { id:11, name: "Lisa", hired: 1999 },
    { id:12, name: "Mark", hired: 2011 }

To display lookup items, a default template is applied based on the following fields of the data source item objects.

  • disabled
    Specifies whether the lookup item is disabled.
  • visible
    Specifies whether the lookup item is visible.
  • html
    Specifies the html code inserted into the item element.
  • text
    Specifies the text inserted into the item element.

If there is no text field in the data source objects, set another data source field to the displayExpr configuration option to enable a user to select the required object by the value of this field.

You can introduce a custom template for lookup items. For this purpose, add a div element with the data-options attribute set to dxTemplate. Provide the item name for the template. In this instance, the template will be applied automatically. See the Customize Widget Item Appearance topic to learn more about templates.

The dxLookup widget uses the byKey() method of the Store wrapped by the DataSource instance passed to the dataSource option of the widget. If you use a CustomStore, you should pass the function implementating the byKey() method to the byKey configuration option of the CustomStore.

Refer to the Add a Widget documentation section to learn how to create widgets in detail.

Show Example:
<div class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">State</div>
        <div class="dx-field-value" data-bind="dxLookup: {
            dataSource: lookupDataSource,
            displayExpr: 'name',
            valueExpr: 'this',
            value: selectedState
<div class="dx-fieldset">
    <div class="dx-field">
        <h1 style="text-align:center;" data-bind="text: state"></h1>
        <img style="margin:5px;" data-bind="attr: { src: imgPath }" />
    <div class="dx-field">
        <div class="dx-field-label">Capital</div>
        <div class="dx-field-value" data-bind="text: capital"></div>
    <div class="dx-field">
        <div class="dx-field-label">Population</div>
        <div class="dx-field-value" data-bind="text: population"></div>
    <div class="dx-field">
        <div class="dx-field-label">Area</div>
        <div class="dx-field-value" data-bind="text: area"></div>
selectedState = ko.observable();
state = ko.observable("none");
capital = ko.observable("none");
area = ko.observable("none");
population = ko.observable("none");
imgPath = ko.observable("");

selectedState.subscribe(function (newValue) {

//An object passed to the dataSource configuration option of the lookup
lookupDataSource = new DevExpress.data.DataSource([]);

//Loads json data and passes it to the DataSource
$.get("/Content/data/states.txt", function (data) {
    for (var i = 0; i < data.length; i++) {
}, "json");

//Generates the path to the required image file
getImagePath = function (name) {
    if (name === undefined)
    return "/Content/images/doc/13_2/PhoneJS/flags/" + name.replace(" ", "") + ".gif";


An object defining configuration options for the dxLookup widget.


This section describes methods that can be used to manipulate a widget.


This section describes events fired by this component.