UI Widgets DateBox

A date box widget.

Included in: dx.phonejs.js, dx.webappjs.js, dx.all.js
DateBox interactive configuration
Copy code
$("#datebox").dxDateBox({
});

The dxDateBox widget displays the date and time value in a specified format, and enables a user to pick the required date/time value.

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

  • jQuery
    Use the dxDateBox jQuery plug-in.

    HTML
    <div id="dateBox"></div>
    JavaScript
    $("#dateBox").dxDateBox({
        min: new Date(2000,0,1),
        max: new Date(2029,11,31),
        value: new Date()
    });
  • Knockout
    Add a div element and apply the dxDateBox binding to this element.

    JavaScript
    var myViewModel = {
        minDate: new Date(2000,0,1),
        maxDate: new Date(2029,11,31),
        currentValue: new Date()
    }
    ko.applyBindings(myViewModel);
    HTML
    <div data-bind="dxDateBox: {
        min: minDate,
        max: maxDate,
        value: currentValue
    }"></div>
  • Angular
    Add a div element and apply the dx-date-box directive to this element.

    JavaScript
    var myApp = angular.module('myApp', ['dx']);
    myApp.controller("demoController", function ($scope) {
        $scope.minDate = new Date(2000,0,1);
        $scope.maxDate = new Date(2029,11,31);
        $scope.currentValue = new Date();
    });
    angular.element(document).ready(function () {
        angular.bootstrap(document, ['myApp']);
    });
    HTML
    <div dx-date-box="{
        min: minDate,
        max: maxDate,
        bindingOptions: {
            value: 'currentValue'
        }
    }"></div>

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

You can find detailed information on principles of working with the widget in the dxDateBox section of the Editor Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController">
    <div class="dx-fieldset">
        <div class="dx-field">
            <div class="dx-field-label">Date</div>
            <div class="dx-field-value" dx-date-box="{ value: date, format: 'date' }"></div>
        </div>
        <div class="dx-field">
            <div class="dx-field-label">Time</div>
            <div class="dx-field-value" dx-date-box="{ value: time, format: 'time' }"></div>
        </div>
        <div class="dx-field">
            <div class="dx-field-label">Date and Time</div>
            <div class="dx-field-value" dx-date-box="{ value: dateTime, format: 'datetime' }"></div>
        </div>
    </div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.date = new Date();
    $scope.time = new Date();
    $scope.dateTime = new Date();
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
<div class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">Date</div>
        <div class="dx-field-value" data-bind="
            dxDateBox: { value: date, format: 'date' }"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Time</div>
        <div class="dx-field-value" data-bind="
            dxDateBox: { value: time, format: 'time' }"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Date and Time</div>
        <div class="dx-field-value" data-bind="
            dxDateBox: { value: dateTime, format: 'datetime' }"></div>
    </div>
</div>
var myViewModel = {
    date: new Date(),
    time: new Date(),
    dateTime: new Date()
}
ko.applyBindings(myViewModel);
<div class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">Date</div>
        <div class="dx-field-value" id="dateFormat"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Time</div>
        <div class="dx-field-value" id="timeFormat"></div>
    </div>
    <div class="dx-field">
        <div class="dx-field-label">Date and Time</div>
        <div class="dx-field-value" id="dateTimeFormat"></div>
    </div>
</div>
$("#dateFormat").dxDateBox({
    value: new Date(),
    format: 'date'
});
$("#timeFormat").dxDateBox({
    value: new Date(),
    format: 'time'
});
$("#dateTimeFormat").dxDateBox({
    value: new Date(),
    format: 'datetime'
});

Configuration

An object defining configuration options for the dxDateBox widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.