SelectBox

The SelectBox widget is an editor that allows an end user to select an item from a drop-down list.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/select_box
Export: default
SelectBox interactive configuration
Copy Code
Copy to Codepen
$("#selectbox").dxSelectBox({
});

You can create the widget using one of the following approaches.

  • jQuery

    HTML
    <div id="selectBox"></div>
    JavaScript
    var states = [
        { id: 1, state: "Alabama", capital: "Montgomery" },
        { id: 2, state: "Alaska", capital: "Juneau" },
        { id: 3, state: "Arizona", capital: "Phoenix" },
        // ...
    ];
    $(function() {
        $("#selectBox").dxSelectBox({
            dataSource: states,
            valueExpr: 'id',
            displayExpr: 'state'
        });
    });
  • Angular

    HTML
    <dx-select-box
        [dataSource]="states"
        valueExpr="id"
        displayExpr="state">
    </dx-select-box>
    JavaScript
    export class AppComponent {
        states = [
            // ...   
        ];
    }
  • AngularJS

    HTML
    <div ng-controller="DemoController">
        <div dx-select-box="{
            dataSource: states,
            valueExpr: 'id',
            displayExpr: 'state'
        }"></div>
    </div>
    JavaScript
    angular.module('DemoApp', ['dx'])
        .controller("DemoController", function ($scope) {
            $scope.states = [
                // ...   
            ];
        });
  • Knockout

    HTML
    <div data-bind="dxSelectBox: {
        dataSource: states,
        valueExpr: 'id',
        displayExpr: 'state'
    }"></div>
    JavaScript
    var viewModel = {
        states: [
            // ...
        ]
    };
    ko.applyBindings(viewModel);
  • ASP.NET MVC Wrappers

    Razor C#
    Razor VB
    @(Html.DevExtreme().SelectBox()
        .ID("selectBox")
        .DataSource(States)
        .DisplayExpr("state")
        .ValueExpr("id")
    )
    @(Html.DevExtreme().SelectBox() _
        .ID("selectBox") _
        .DataSource(States) _
        .DisplayExpr("state") _
        .ValueExpr("id")
    )

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

View Demo

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the SelectBox widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

Default Item Template

This section lists the data source fields that are used in a default item template.

By default, a predefined item template is applied to display the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source.

See Also