Search results

Migration from Essential JS 1

This article describes the API migration process of DateTimePicker component from Essential JS 1 to Essential JS 2.

DateTime selection

Behavior API in Essential JS 1 API in Essential JS 2
Setting the value Property: value
   <ej-date-time-picker id="datetime"  value="DateTime.Now"></ej-date-time-picker>
Property: value
   <ejs-datetimepicker id="datetime" value="DateTime.Now"></ejs-datetimepicker>

DateTime format

Behavior API in Essential JS 1 API in Essential JS 2
Display datetime format Property: date-time-format
   <ej-date-time-picker id="datetime" value="DateTime.Now" date-time-format="dd/MM/yyyy hh:mm tt"></ej-date-time-picker>
Property: format
    <ejs-datetimepicker id="datetime" format="dd/MM/yyyy hh:mm a" value="DateTime.Now"></ejs-datetimepicker>
Day header format Property: day-header-format
     <ej-date-time-picker id="datetime" day-header-format="Short"></ej-date-time-picker>
Not Applicable

Calendar views

Behavior API in Essential JS 1 API in Essential JS 2
Start Property: start-level
    <ej-date-time-picker id="datetime" start-level="Year"></ej-date-time-picker>
Property: start
    <ejs-datetimepicker id="datetime" start="Decade"></ejs-datetimepicker>
Depth Property: depth-level
    <ej-date-time-picker id="datetime" depth-level="Year"></ej-date-time-picker>
Property: depth
    <ejs-datetimepicker id="datetime" depth="Year"></ejs-datetimepicker>

Date range

Behavior API in Essential JS 1 API in Essential JS 2
Minimum datetime Property: min-date-time
    <ej-date-time-picker id="datetime" min-date-time="new DateTime(2018,9,3,4,00,00)"></ej-date-time-picker>
Property: min
    <ejs-datetimepicker id="datetime" min="new DateTime(2018,9,3,4,00,00)"></ejs-datetimepicker>
Maximum datetime Property: max-date-time
    <ej-date-time-picker id="datetime" max-date-time="new DateTime(2019,1,1,6,00,00)"></ej-date-time-picker>
Property: max
    <ejs-datetimepicker id="datetime" max="new DateTime(2019,1,1,6,00,00)"></ejs-datetimepicker>

Disabled dates

Behavior API in Essential JS 1 API in Essential JS 2
Disabled dates Not Applicable Event: renderDayCell
    <ejs-datetimepicker id="datetime" renderdaycell="disableDatetime"></ejs-datetimepicker>
  
    <script>
    function disableDatetime(args) {
        if (args.date.getDay() === 0 || args.date.getDay() === 6) {
            args.isDisabled = true;
        }
    }
    </script>

Customization

Behavior API in Essential JS 1 API in Essential JS 2
css Class Property: css-class
    <ej-date-time-picker id="datetime"  css-class="gradient-lime"></ej-date-time-picker>
Property: cssClass
    <ejs-datetimepicker id="datetime" cssClass="gradient-lime"></ejs-datetimepicker>
Show button Property: css-class
    <ej-date-time-picker id="datetime" css-class="e-custom-class"></ej-date-time-picker>

    <style>
        .e-datetime-popup.e-popup.e-custom-class .e-button-container {
            display: none !important;
        }
    </style>
Property: showTodayButton
    <ejs-datetimepicker id="datetime" showTodayButton="false"></ejs-datetimepicker>
Show other month dates Property: show-other-months
    <ej-date-time-picker id="datetime" show-other-months="false"></ej-date-time-picker>
    <ejs-datetimepicker id="datetime"></ejs-datetimepicker><br /><br />

    <style>
        .e-DateTimePicker .e-calendar .e-content tr.e-month-hide, .e-DateTimePicker .e-calendar .e-content td.e-other-month > .e-day {
            visibility: none;
        }

        .e-DateTimePicker .e-calendar .e-content td.e-month-hide, .e-DateTimePicker .e-calendar .e-content td.e-other-month {
            pointer-events: none;
            touch-action: none;
        }
    </style>
Show popup button Property: show-popup-button
    <ej-date-time-picker id="datetime" show-popup-button="false"></ej-date-time-picker>
Event: focus
    <ejs-datetimepicker id="datetime" focus="onFocus"></ejs-datetimepicker>

    <script>
        function onFocus(args) {
            var datetimepicker = document.getElementById("datetime").ej2_instances[0];
            datetimepicker.show();
        }
    </script>

    <style>
        .e-control-wrapper .e-input-group-icon.e-date-icon {
            display: none;
        }
    </style>
Show rounded corner Property: show-rounded-corner
    <ej-date-time-picker id="datetime" show-rounded-corner="true"></ej-date-time-picker>
Property: css-class
    <ejs-datetimepicker id="datetime" cssclass="e-custom-style"></ejs-datetimepicker>

    <style>
        .e-control-wrapper.e-custom-style.e-date-wrapper.e-input-group {
            border-radius: 4px;
        }
    </style>
Skip a month Property: step-months
    <ej-date-time-picker id="datetime" step-months="2"></ej-date-time-picker>
Method: navigateTo()
    <ejs-datetimepicker id="datetime" value="new DateTime(2018,09,04,5,00,00)" open="onOpen"></ejs-datetimepicker>

    <script>
        function onOpen(args) {
            var datetimepicker = document.getElementById("datetime").ej2_instances[0];
            datetimepicker.navigateTo('Year', new Date("03/18/2018"));
        }
    </script>
Show tooltip Property: show-tooltip
    <ej-date-time-picker id="datetime" show-tooltip="false"></ej-date-time-picker>
Not Applicable
Interval Property: interval
    <ej-date-time-picker id="datetime" interval="60"></ej-date-time-picker>
Property: step
    <ejs-datetimepicker id="datetime" step="60"></ejs-datetimepicker>
Button text Property: button-text
    <ej-date-time-picker id="datetime"><br/><e-date-time-button-text done="Done" time-now="Time Now" today="Today" time-title="Time"/><br/></ej-date-time-picker>
Method: load()
    <ejs-datetimepicker id="datetime" locale="en"></ejs-datetimepicker>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            datetimepicker = document.getElementById('datetime').ej2_instances[0];
            var L10n = ej.base.L10n;
            L10n.load({
                'en': {
                    'datetimepicker': { today: 'Now' }
                }
            });
        });
    </script>
Enable animation Property: enable-animation
    <ej-date-time-picker id="datetime" enable-animation="false"></ej-date-time-picker>
Not Applicable
Focus in method Not Applicable Method: focusIn()
    <ejs-datetimepicker id="datetime"></ejs-datetimepicker>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var datetimeObject = document.getElementById("datetime").ej2_instances[0];
            datetimeObject.focusIn();
        });
    </script>
Focus out method Not Applicable Method: focusOut()
    <ejs-datetimepicker id="datetime"></ejs-datetimepicker>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var datetimeObject = document.getElementById("datetime").ej2_instances[0];
            datetimeObject.focusOut();
        });
    </script>
Prevent close Not Applicable Event: close
    <ejs-datetimepicker id="datetime" close="onClose"></ejs-datetimepicker>

    <script>
        function onClose(args) {
            args.cancel = true;
        }

        document.addEventListener('DOMContentLoaded', function () {
            var datetimeObject = document.getElementById("datetime").ej2_instances[0];
            datetimeObject.show();
        });
    </script>
Prevent open Not Applicable Event: open
    <ejs-datetimepicker id="datetimepicker" open="onOpen"></ejs-datetimepicker>

    <script>
        function onOpen(args) {
            args.cancel = true;
        }
    </script>

Accessibility

Behavior API in Essential JS 1 API in Essential JS 2
Enable RTL Property: enable-rtl
    <ej-date-time-picker id="datetime" enable-rtl="true"></ej-date-time-picker>
Property: enableRtl
    <ejs-datetimepicker id="datetime" enableRtl="true"></ejs-datetimepicker>

Persistence

Behavior API in Essential JS 1 API in Essential JS 2
Enable Persistence Property: enable-persistence
    <ej-date-time-picker id="datetime" enable-persistence="true"></ej-date-time-picker>
Property: enablePersistence
    <ejs-datetimepicker id="datetime" enablePersistence="true"></ejs-datetimepicker>

Validation

Behavior API in Essential JS 1 API in Essential JS 2
Validation rules Property: validation-rules
    <ej-date-time-picker id="datetime" validation-rules='new Dictionary<string, object>() {{ "required",true}}'></ej-date-time-picker>
Property: rules
    <form id="form-element" class="form-vertical">
        <ejs-datetimepicker id="datetime"></ejs-datetimepicker>
    </form>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var options = { rules: { 'datetime': { required: true } } };
            var formObject = new ej.inputs.FormValidator('#form-element', options);
        });
    </script>  
Validation message Property: validation-messages
    <ej-date-time-picker id="datetime" validation-rules='new Dictionary<string, object>() {{ "required",true}}' validation-messages='new Dictionary<string, object>() {{ "required","Required Date Time value"}}'></ej-date-time-picker>
Property: rules
    <form id="form-element" class="form-vertical">
        <ejs-datetimepicker id="datetime"></ejs-datetimepicker>
    </form>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var options = { rules: { 'datetime': { required: true } },
                customPlacement: (inputElement, errorElement) => { inputElement.parentElement.parentElement.appendChild(errorElement);
        }};
        var formObject = new ej.inputs.FormValidator('#form-element', options);
        });
    </script>

Common

Behavior API in Essential JS 1 API in Essential JS 2
Width Property: width
    <ej-date-time-picker id="datetime" width="200"></ej-date-time-picker>
Property: width
    <ejs-datetimepicker id="datetime" width="200"></ejs-datetimepicker>
Read only Property: read-only
    <ej-date-time-picker id="datetime" read-only="true"></ej-date-time-picker>
Property: readonly
    <ejs-datetimepicker id="datetime" readonly="true"></ejs-datetimepicker>
Show Clear Button Not Applicable Property: showClearButton
    <ejs-datetimepicker id="datetime" showClearButton="true"></ejs-datetimepicker>
Height Property: height
    <ej-date-time-picker id="datetime" height="35"></ej-date-time-picker>
Property: cssClass
    <ejs-datetimepicker id="datetime" cssclass="e-custom-style"></ejs-datetimepicker>

    <style>
        .e-control-wrapper.e-custom-style.e-date-wrapper.e-input-group {
            height: 35px;
        }
    </style>
Html Attributes Property: html-attributes
    @{ IDictionary<string, object> htmlAttr = new Dictionary<string, object>();
       htmlAttr.Add("required", "required");
    }

    <ej-date-time-picker id="datetime" html-attributes="htmlAttr"></ej-date-time-picker>
Not Applicable
Week Number Property: week-number
    <ej-date-time-picker id="datetime" week-number="true"></ej-date-time-picker>
Property: weekNumber
    <ejs-datetimepicker id="datetime" weekNumber="true"></ejs-datetimepicker>
Watermark Text Property: watermark-text
    <ej-date-time-picker id="datetime" watermark-text="Enter date and time"></ej-date-time-picker>
Property: placeholder
    <ejs-datetimepicker id="datetime" placeholder="Enter date and time"></ejs-datetimepicker>
Disable and enable Property: enabled
    <ej-date-time-picker id="datetime" enabled="false"></ej-date-time-picker>
Property: enabled
    <ejs-datetimepicker id="datetime" enabled="false"></ejs-datetimepicker>
Allow Editing Property: allow-edit
    <ej-date-time-picker id="datetime" allow-edit="false"></ej-date-time-picker>
Property: allowEdit
    <ejs-datetimepicker id="datetime" allowEdit="false"></ejs-datetimepicker>
z Index Property: css-class
    <ej-date-time-picker id="datetime" css-class="e-custom-class"></ej-date-time-picker>

    <style>
        .e-datetime-popup.e-popup.e-custom-class {
            z-index: 100 !important;
        }
    </style>
Property: zIndex
    <ej-date-time-picker id="datetime" zIndex="100"></ej-date-time-picker>
Float Label Type Not Applicable Property: floatLabelType
    <ejs-datetimepicker id="datetime" placeholder="Enter date and time" floatLabelType="Syncfusion.EJ2.Inputs.FloatLabelType.Auto"></ejs-datetimepicker>
Render day cell Not Applicable Event: renderDayCell
    <ejs-datetimepicker id="datetime" renderdaycell="onRenderCell"></ejs-datetimepicker>

    <script>
        function onRenderCell() { }
    </script>
Focus In event Event: focus-in
    <ej-date-time-picker id="datetime" focus-in="onFocus"></ej-date-time-picker>
    <script>
        function onFocus() { }
    </script>
Event: focus
    <ejs-datetimepicker id="datetime" focus="onFocus"></ejs-datetimepicker>

    <script>
        function onFocus() { }
    </script>
Focus out event Event: focus-out
    <ej-date-time-picker id="datetime" focus-out="onFocusout"></ej-date-time-picker>

    <script>
        function onFocusout() { }
    </script>
Event: blur
    <ejs-datetimepicker id="datetime" blur="onBlur"></ejs-datetimepicker>

    <script>
        function onBlur() { }
    </script>
  
Change event Event: change
    <ej-date-time-picker id="datetime" change="onChange"></ej-date-time-picker>

    <script>
        function onChange() { }
    </script>
Event: change
    <ejs-datetimepicker id="datetime" blur="onChange"></ejs-datetimepicker>

    <script>
        function onChange() { }
    </script>
  
Created event Event: create
    <ej-date-time-picker id="datetime" create="onCreate"></ej-date-time-picker>

    <script>
        function onCreate() { }
    </script>
Event: created
    <ejs-datetimepicker id="datetime" created="onCreated"></ejs-datetimepicker>

    <script>
        function onCreated() { }
    </script>
Destroy event Event: destroy
    <ej-date-time-picker id="datetime" destroy="onDestroy"></ej-date-time-picker>

    <script>
        function onDestroy() { }
    </script>
Event: destroyed
    <ejs-datetimepicker id="datetime" destroyed="onDestroyed"></ejs-datetimepicker>

    <script>
        function onDestroyed() { }
    </script>

Globalization

Behavior API in Essential JS 1 API in Essential JS 2
Locale Property: locale
    <ej-date-time-picker id="datetime" locale="en-US"></ej-date-time-picker>
Property: locale
    <ejs-datetimepicker id="datetime" locale="en"></ejs-datetimepicker>
First day of week Property: start-day
    <ej-date-time-picker id="datetime" start-day="2"></ej-date-time-picker>
Property: firstDayOfWeek
    <ejs-datetimepicker id="datetime" firstDayOfWeek="2"></ejs-datetimepicker>

Strict mode

Behavior API in Essential JS 1 API in Essential JS 2
Strict mode Property: enable-strict-mode
    <ej-date-time-picker id="datetime" enable-strict-mode="true"></ej-date-time-picker>
Property: strictMode
    <ejs-datetimepicker id="datetime" strictMode="true" min="new DateTime(2017,5,5,12,00,00)" max="new DateTime(2017,05,25,12,00,00)" value="new DateTime(2017,05,28,12,00,00)"></ejs-datetimepicker>

Open and Close

Behavior API in Essential JS 1 API in Essential JS 2
Close Event: close
    <ej-date-time-picker id="datetime" close="onClose"></ej-date-time-picker>

    <script>
        function onClose() { }
    </script>
Event: close
    <ejs-datetimepicker id="datetime" close="onClose"></ejs-datetimepicker>

    <script>
        function onClose() { }
    </script>
Hide Method: hide()
    <ej-date-time-picker id="datetime" create="onCreate"></ej-date-time-picker>

    <script>
        function onCreate(args) {
            var datetimeObject = $("#datetime").data("ejDateTimePicker");
            datetimeObject.show();
            datetimeObject.hide();
        }
    </script>
Method: hide()
    <ejs-datetimepicker id="datetime"></ejs-datetimepicker>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var datetimepickerObject = document.getElementById("datetime").ej2_instances[0];
            datetimepickerObject.show();
            datetimepickerObject.hide();
        });
    </script>
Open Event: open
    <ej-date-time-picker id="datetime" open="onOpen"></ej-date-time-picker>

    <script>
        function onOpen()
    </script>
Event: open
    <ejs-datetimepicker id="datetime" open="onOpen"></ejs-datetimepicker>

    <script>
        function onOpen()
    </script>
Show Method: show()
    <ej-date-time-picker id="datetime" create="onCreate"></ej-date-time-picker>

    <script>
        function onCreate(args) {
            var datetimeObject = $("#datetime").data("ejDateTimePicker");
            datetimeObject.show();
        }
    </script>
Method: show()
    <ejs-datetimepicker id="datetime"></ejs-datetimepicker>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var datetimepickerObject = document.getElementById("datetime").ej2_instances[0];
            datetimepickerObject.show();
        });
    </script>

View navigation

Behavior API in Essential JS 1 API in Essential JS 2
Navigate to Not Applicable Method: navigateTo()
    <ejs-datetimepicker id="datetime" open="onOpen"></ejs-datetimepicker>

    <script>
        function onOpen(args) {
            var datetimeObject = document.getElementById("datetime").ej2_instances[0];
            datetimeObject.navigateTo('Year', new Date("03/18/2018"));
        }
    </script>
Navigation Not Applicable Event: navigated
    <ejs-datetimepicker id="datetime" navigated="onNavigated"></ejs-datetimepicker>

    <script>
        function onNavigated() { }
    </script>
Drill down Property: timeDrillDown
    <ej-date-time-picker id="datetime"><br/><e-time-drill-down auto-close="true" enabled="true" interval="10" show-meridian="true"></ej-date-time-picker>
Not Applicable