Search results

Migration from Essential JS 1 in JavaScript DateTimePicker control

27 Jul 2021 / 14 minutes to read

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
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
value: new Date("5/5/2014 12:00 PM")
});
property: value
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
value: new Date("05/11/2017 12:00 PM")
});
datetimepickerObject.appendTo('#element');

DateTime Format

Behavior API in Essential JS 1 API in Essential JS 2
Display the datetime format property: dateTimeFormat
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
value: new Date("5/5/2014 12:00 PM"),
dateTimeFormat: "dd/MM/yyyy hh:mm tt"
});
property: format
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
value: new Date("05/11/2017 12:00 PM"),
format: 'dd/MM/yyyy hh:mm a'
});
datetimepickerObject.appendTo('#element');
Day header format property: dayHeaderFormat
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
dayHeaderFormat: "short"
});
Not Applicable

Calendar Views

Behavior API in Essential JS 1 API in Essential JS 2
Start view property: startLevel
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
startLevel: ej.DateTimePicker.Level.Year
});
property: start
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
start:'Decade'
});
datetimepickerObject.appendTo('#element');
Depth view property: depthLevel
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
depthLevel: ej.DateTimePicker.Level.Year
});
property: depth
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
depth:'Year'
});
datetimepickerObject.appendTo('#element');

Date Range

Behavior API in Essential JS 1 API in Essential JS 2
Minimum datetime property: minDateTime
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
minDateTime: new Date("5/1/2013 10:00 AM")
});
property: min
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
min: new Date("5/1/2013 10:00 AM"
)});
datetimepickerObject.appendTo('#element');
Maximum datetime property: maxDateTime
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
maxDateTime: new Date("5/1/2013 10:00 AM")
});
property: max
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
max : new Date("5/30/2015 10:00 PM")
});
datetimepickerObject.appendTo('#element');

Disabled Dates

Behavior API in Essential JS 1 API in Essential JS 2
Disabled dates property: disabledDateTimeRanges
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
disableDateTimeRanges: [{ startDateTime: new Date("11/30/2018 11:59 PM"),       endDateTime:new Date("12/1/2018 11:59 PM")    }]
});
Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
renderDayCell: disableDate
});
datetimepickerObject.appendTo('#element');
function disableDate(args: RenderDayCellEventArgs): void {
if (args.date.getDay() === 0 || args.date.getDay() === 6) {
    args.isDisabled = true;
}
}

Customization

Behavior API in Essential JS 1 API in Essential JS 2
CSS Class property: cssClass
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
cssClass: "gradient-lime"
});
property: cssClass
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
cssClass: 'e-custom-style'
});
datetimepickerObject.appendTo('#element');
Show/Hide the today button Can be achieved by
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
cssClass: "e-custom-class"
});
Copied to clipboard
.e-datetime-popup.e-popup.e-custom-class .e-button-container{
display: none !important;
}
property: showTodayButton
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
showTodayButton: false
});
datetimepickerObject.appendTo('#element');
Show/Hide the other month dates property: showOtherMonths
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
showOtherMonths: false
});
Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker();
datetimepickerObject.appendTo('#element');
Copied to clipboard
.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;
}
Show/Hide the popup button property: showPopupButton
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
showPopupButton: false
});
Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
focus: onFocus
});
datetimepickerObject.appendTo('#element');
function onFocus(args: FocusEventArgs) {
datetimepickerObject.show();
}
Copied to clipboard
.e-control-wrapper .e-input-group-icon.e-date-icon {
display: none;
}
Enable/Disable the rounded corner property: showRoundedCorner
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
showRoundedCorner: true
});
Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
cssClass: 'e-custom-style'
});
datetimepickerObject.appendTo('#element');
Copied to clipboard
.e-control-wrapper.e-custom-style.e-date-wrapper.e-input-group {
border-radius: 4px;
}
Skip a month property: stepMonths
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
stepMonths: 2
});
Method: navigateTo()
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
value: new Date("09/04/2019"),
open:onOpen
});
datetimepickerObject.appendTo('#element');
function onOpen(args:any){
datepicker.navigateTo('Year', new Date("03/18/2018"));
}
Show/Hide the tooltip property: showTooltip
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
showTooltip: false
});
Not Applicable
Interval property: interval
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
interval: 60
});
property: step
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
step: 60
});
datetimepickerObject.appendTo('#element');
Button text property: buttonText
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
buttonText : { today: "Today", timeNow: "Time Now",  done: "Done",  timeTitle: "Time" }
});
Can be achieved by
Copied to clipboard
L10n.load({ 'en': {  'DateTimePicker': { today:'Now' } }});
let datetimepickerObject: DateTimePicker = new DateTimePicker({
locale: 'en'
});
datetimepickerObject.appendTo('#element');
Enable/Disable the animation property: enableAnimation
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
enableAnimation : false
});
Not Applicable
FocusIn method Not Applicable Method: focusIn()
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
placeholder: 'Enter date'
});
datetimepickerObject.appendTo('#element');
datetimepickerObject.focusIn();
FocusOut method Not Applicable Method: focusOut()
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
placeholder: 'Enter date'
});
datetimepickerObject.appendTo('#element');
datetimepickerObject.focusOut();
Prevent popup close Not Applicable Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
close: function (args: PreventableEventArgs) {
    args.preventDefault();
}
});
datetimepickerObject.appendTo('#element');
datetimepickerObject.show();
Prevent popup open Not Applicable Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
open: function (args: PreventableEventArgs) {
    args.preventDefault();
}
});
datetimepickerObject.appendTo('#element');
datetimepickerObject.show();

Accessibility

Behavior API in Essential JS 1 API in Essential JS 2
Enable/Disable the RTL property: enableRTL
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
enableRTL : true
});
property: enableRtl
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
enableRtl : true
});
datetimepickerObject.appendTo('#element');

Persistence

Behavior API in Essential JS 1 API in Essential JS 2
Enable/Disable the persistence property: enablePersistence
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
enablePersistence : true
});
property: enablePersistence
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
enablePersistence : true
});
datetimepickerObject.appendTo('#element');

Validation

Behavior API in Essential JS 1 API in Essential JS 2
Validation rules property: validationRules
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
validationRules : {required : true}
});
Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
placeholder: 'Enter datetime',
value: new Date()
});
datepickerObject.appendTo('#element');
let options: FormValidatorModel = {
rules: {
    'datevalue': { required: true }
}
}
let formObject: FormValidator = new FormValidator('#form-element', options);
Validation message property: validationMessage
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
validationRules : {required : true},
validationMessage : {required: "Required DateTime value" }
});
Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
placeholder: 'Enter dateTime',
value: new Date()
});
datetimepickerObject.appendTo('#element');
let options: FormValidatorModel = {
rules: {
    'datevalue': { required: [true, 'DateTime value required']  }
},
customPlacement: function (inputElement, errorElement) {
    (<HTMLElement>inputElement).parentElement.parentElement.appendChild(errorElement);
}
}
let formObject: FormValidator = new FormValidator('#form-element', options);

Common

Behavior API in Essential JS 1 API in Essential JS 2
Width property: width
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
width: 200
});
property: width
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
width: '200px'
});
datetimepickerObject.appendTo('#element');
Readonly property: readOnly
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
readOnly : true
});
property: readonly
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
readonly:true,
value:new Date()
});
datetimepickerObject.appendTo('#element');
Show/Hide the clear button Not Applicable property: showClearButton
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
showClearButton: true
});
datetimepickerObject.appendTo('#element');
Height property: height
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
height: 35
});
Can be achieved by
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
cssClass: 'e-custom-style'
});
datetimepickerObject.appendTo('#element');
Copied to clipboard
.e-control-wrapper.e-custom-style.e-date-wrapper.e-input-group{
height: 35px;
}
Html attributes property: htmlAttributes
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   htmlAttributes : {required:"required"}
});
Not Applicable
Show/Hide the week number property: weekNumber
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   weekNumber : true
});
property: weekNumber
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
weekNumber:true
});
datetimepickerObject.appendTo('#element');
Watermark text property: watermarkText
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   watermarkText: "Enter date"
});
property: placeholder
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
placeholder: 'Enter date'
});
datetimepickerObject.appendTo('#element');
Disable/Enable property: enabled
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   enabled: false
});
property: enabled
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
enabled:false
});
datetimepickerObject.appendTo('#element');
Enable/Disable the textbox editing property: allowEdit
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   allowEdit : true
});
property: allowEdit
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
allowEdit : true
});
datetimepickerObject.appendTo('#element');
zIndex Can be achieved by
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   cssClass: "e-custom-class"
});
Copied to clipboard
.e-datetime-popup.e-popup.e-custom-class {
z-index: 100 !important;
}
property: zIndex
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
zIndex: 100
});
datetimepickerObject.appendTo('#element');
Specify the placeholder text behavior Not Applicable property: floatLabelType
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
placeholder: 'Enter date',
floatLabelType: 'Auto'
});
datetimepickerObject.appendTo('#element');
Event callback for each cell creation Not Applicable Event: renderDayCell
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
renderDayCell: onRenderCell
});
datetimepickerObject.appendTo('#element');
function onRenderCell(args: RenderDayCellEventArgs): void {/* code block*/}
FocusIn event Event: focusIn
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   focusIn: function (args) {/* code block*/}
});
Event: focus
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
focus: onFocus
});
datetimepickerObject.appendTo('#element');
function onFocus(args: FocusEventArgs): void {/* code block*/}
FocusOut event Event: focusOut
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   focusOut: function (args) {/* code block*/}
});
Event: blur
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
blur: onBlur
});
datetimepickerObject.appendTo('#element');
function onBlur(args: BlurEventArgs): void {/* code block*/}
Change event Event: change
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   change: function (args) {/* code block*/}
});
Event: change
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
change: onChange
});
datetimepickerObject.appendTo('#element');
function onChange(args: ChangedEventArgs): void {/* code block*/}
Create event Event: create
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   create: function (args) {/* code block*/}
});
Event: created
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
created: onCreate
});
datetimepickerObject.appendTo('#element');
function onCreate(args): void {/* code block*/}
Destroy event Event: destroy
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   destroy: function (args) {/* code block*/}
});
Event: destroyed
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
destroyed: onDestroy
});
datetimepickerObject.appendTo('#element');
function onDestroy(args): void {/* code block*/}

Globalization

Behavior API in Essential JS 1 API in Essential JS 2
Locale property: locale
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   locale: "en-US"
});
property: locale
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
locale: 'en'
});
datetimepickerObject.appendTo('#element');
First day of week property: startDay
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
   startDay: 2
});
property: firstDayOfWeek
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
firstDayOfWeek: 2
});
datetimepickerObject.appendTo('#element');

Strict Mode

Behavior API in Essential JS 1 API in Essential JS 2
Strict mode property: enableStrictMode
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
enableStrictMode : true
});
property: strictMode
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
strictMode: true,
value: new Date('5/28/2017'),
min: new Date('5/5/2017'),
max: new Date('5/25/2017')
});
datetimepickerObject.appendTo('#element');

Open and Close

Behavior API in Essential JS 1 API in Essential JS 2
Close Event: close
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
close: function (args) {/* code block*/}}
});
Event: close
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
close: function (args: PreventableEventArgs) {/* code block*/}
});
datetimepickerObject.appendTo('#element');
Hide Method: hide()
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
});
datetimeObj.hide();
Method: hide()
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
value: new Date("05/11/2017")
});
datetimepickerObject.appendTo('#element');
datetimepickerObject.hide();
Open Event: open
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
open: function (args) {/* code block*/}}
});
Event: open
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
open: function (args: PreventableEventArgs) {/* code block*/}
});
datetimepickerObject.appendTo('#element');
Show Method: show()
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
});
datetimeObj.show();
Method: show()
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
value: new Date("05/11/2017")
});
datetimepickerObject.appendTo('#element');
datetimepickerObject.show();

View Navigation

Behavior API in Essential JS 1 API in Essential JS 2
Navigate to specific month Not Applicable Method: navigateTo()
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
value: new Date("09/04/2019"),
open:onOpen
});
datetimepickerObject.appendTo('#element');
function onOpen(args:any){
datepicker.navigateTo('Year', new Date("03/18/2018"));
}
Navigation callback Not Applicable Event: navigated
Copied to clipboard
let datetimepickerObject: DateTimePicker = new DateTimePicker({
navigated: onNavigate
});
datetimepickerObject.appendTo('#element');
function onNavigate(args: NavigatedEventArgs) {/* code block*/}
Drill down property: timeDrillDown
Copied to clipboard
var datetimeObj = new ej.DateTimePicker($("#datetimepicker"), {
timeDrillDown: { enabled: true, showMeridian: true, autoClose: true, interval: 10 }
});
Not Applicable