Search results

Migration from Essential JS 1 in JavaScript TimePicker control

02 Dec 2021 / 10 minutes to read

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

Time Selection

Behavior API in Essential JS 1 API in Essential JS 2
Setting the value Property: value
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
value: new Date("5/5/2014 12:00 PM")
});
Property: value
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
value: new Date("05/11/2017 2:00 PM")
});
timepickerObject.appendTo('#element');

Time Format

Behavior API in Essential JS 1 API in Essential JS 2
Display time format Property: timeFormat
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
timeFormat: 'hh:mm:ss tt'
});
Property: format
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
format:'hh:mm:ss'
});
timepickerObject.appendTo('#element');

Time Range

Behavior API in Essential JS 1 API in Essential JS 2
Minimum time Property: minTime
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
minTime: '10:00 AM'
});
Property: min
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
min: new Date('5/5/2019 3:00 AM')
});
timepickerObject.appendTo('#element');
Maximum time Property: maxTime
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
maxTime: '10:00 AM'
});
Property: Max
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
max: new Date('5/5/2019 8:00 AM')
});
timepickerObject.appendTo('#element');
Set current time Method: setCurrentTime()
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
});
console.log(timeObj.setCurrentTime());
Can be achieved by
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
value: new Date()
});
timepickerObject.appendTo('#element');

Disabled Time Ranges

Behavior API in Essential JS 1 API in Essential JS 2
Disable time ranges Property: disableTimeRanges
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
disableTimeRanges :[{ startTime: '3:00 AM', endTime: '6:00 AM' }, { startTime: '1:00 PM', endTime: '3:00 PM' }, { startTime: '8:00 PM', endTime: '10:00 PM' }]
});
Can be achieved by
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
itemRender: itemRanderHandler
});
timepickerObject.appendTo('#element');

function itemRenderHandler(args: ItemEventArgs): void {
if (args.value.getHours() === 4) {
    args.isDisabled = true;
}
}

Customization

Behavior API in Essential JS 1 API in Essential JS 2
CSS Class Property: CssClass
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
cssClass :'gradient-lime'
});
Property: CssClass
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
cssClass: 'e-custom-style'
});
timepickerObject.appendTo('#element');
Popup list customization Not Applicable Event: itemRender
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
itemRender: itemRanderHandler
});
timepickerObject.appendTo('#element');

function itemRenderHandler(args: ItemEventArgs): void { /* code block*/}
Show/Hide the popup button Property: showPopupButton
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
showPopupButton : false
});
Can be achieved by
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
focus: onFocus
});
timepickerObject.appendTo('#element');

function onFocus(args: FocusEventArgs): void {
timepickerObject.show();
}
Copied to clipboard
.e-control-wrapper .e-input-group-icon.e-time-icon {
display: none;
}
Enable/Disable the rounded corner Property: showRoundedCorner
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
showRoundedCorner : true
});
Can be achieved by
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
cssClass: 'e-custom-style'
});
timepickerObject.appendTo('#element');
Copied to clipboard
.e-control-wrapper.e-custom-style.e-time-wrapper.e-input-group {
border-radius: 4px;
}
Enable/Disable the animation Property: enableAnimation
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
enableAnimation : true
});
Not Applicable
Interval Property: interval
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
interval : 120
});
Property: step
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
step: 120
});
timepickerObject.appendTo('#element');
FocusIn event Event: focusIn
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
focusIn: function (args) {/* code block*/}
});
Event: focus
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
focus: onFocus
});
timepickerObject.appendTo('#element');
function onFocus(args:any){ /* code block*/}
FocusOut event Event: focusOut
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
focusIn: function (args) {/* code block*/}
});
Event: blur
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
blur: onBlur
});
timepickerObject.appendTo('#element');
function onBlur(args: BlurEventArgs) { /* code block*/}
FocusIn method Not Applicable Method: focusIn()
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
value : new Date()
});
timepickerObject.appendTo('#element');
timepickerObject.focusIn();
FocusOut method Not Applicable Event: focusOut
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
value : new Date()
});
timepickerObject.appendTo('#element');
timepickerObject.focusOut();
Prevent popup close Not Applicable Event: close
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
close: function (args: PreventableEventArgs) {
    args.cancel = true;  
}
});
timepickerObject.appendTo('#element');
timepickerObject.show();
Prevent popup open Not Applicable Event: open
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
open: function (args: PreventableEventArgs) {
    args.cancel = true;  
}
});
timepickerObject.appendTo('#element');
timepickerObject.show();

Accessibility

Behavior API in Essential JS 1 API in Essential JS 2
Enable/Disable the RTL Property: enableRTL
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
enableRTL: true
});
Property: enableRtl
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
enableRtl: true
});
timepickerObject.appendTo('#element');

Persistence

Behavior API in Essential JS 1 API in Essential JS 2
Enable/Disable the persistence Property: enablePersistence
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
enablePersistence: true
});
Property: enablePersistence
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
enablePersistence: true
});
timepickerObject.appendTo('#element');

Validation

Behavior API in Essential JS 1 API in Essential JS 2
Validation rules Property: validationRules
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
validationRules : {required : true},
});
Can be achieved by
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
placeholder: 'Enter Time',
value: new Date()
});
timepickerObject.appendTo('#element');
let options: FormValidatorModel = {
rules: {
    'timevalue': { required: true }
}
}
let formObject: FormValidator = new FormValidator('#form-element', options);
Validation message Property: validationMessages
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
validationRules : {required : true},
validationMessages : {required: "Required time value" }
});
Can be achieved by
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
placeholder: 'Enter Time',
value: new Date()
});
timepickerObject.appendTo('#element');
let options: FormValidatorModel = {
rules: {
    'timevalue': { required: [true, 'Time 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 timeObj = new ej.TimePicker($("#timepicker"), {
width: 200
});
Property: width
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
width: '200px'
});
timepickerObject.appendTo('#element');
Readonly Property: readOnly
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
readOnly: true
});
Property: Readonly
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
readonly: true,
value: new Date()
});
timepickerObject.appendTo('#element');
Show/Hide the clear button Not Applicable Property: showClearButton
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
showClearButton: true,
});
timepickerObject.appendTo('#element');
Height Property: Height
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
height: "50px"
});
Can be achieved by
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
cssClass: 'e-custom-style',
});
timepickerObject.appendTo('#element');
Copied to clipboard
.e-control-wrapper.e-custom-style.e-time-wrapper.e-input-group {
height: 35px;
}
Html Attributes Property: HtmlAttributes
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
htmlAttributes : {required:"required"}
});
Not Applicable
Watermark text Property: watermarkText
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
watermarkText : "Enter Time"
});
Property: placeholder
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
placeholder: 'Select a Time'
});
timepickerObject.appendTo('#element');
Enable the TimePicker Property: enabled
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
enabled : true
});
Property: enabled
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
enabled: true
});
timepickerObject.appendTo('#element');
Disable the TimePicker Method: disable()
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
});
timeObj.disable();
Property: enabled
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
enabled: false
});
timepickerObject.appendTo('#element');
Enable/Disable the textBox editing Not Applicable Property: allowEdit
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
allowEdit: false
});
timepickerObject.appendTo('#element');
zIndex Not Applicable Property: zIndex
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
zIndex: 2000
});
timepickerObject.appendTo('#element');
Specify the placeholder text behavior Not Applicable Property: floatLabelType
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
floatLabelType: 'Always',
placeholder: 'Select a time'
});
timepickerObject.appendTo('#element');

Globalization

Behavior API in Essential JS 1 API in Essential JS 2
Locale Property: locale
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
locale:"en-US"
});
Property: locale
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
locale: 'en',
});
timepickerObject.appendTo('#element');

Strict Mode

Behavior API in Essential JS 1 API in Essential JS 2
Strict mode Property: enableStrictMode
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
enableStrictMode: true
});
Property: strictMode
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
strictMode: true,
});
timepickerObject.appendTo('#element');

Open and Close

Behavior API in Essential JS 1 API in Essential JS 2
Close Event: close
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
close: function(args){ /* code block*/}
});
Event: close
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
close: function (args: PreventableEventArgs) { /* code block*/}
});
timepickerObject.appendTo('#element');
Open Event: open
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
open: function(args){ /* code block*/}
});
Event: open
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
open: function (args: PreventableEventArgs) { /* code block*/}
});
timepickerObject.appendTo('#element');
Hide Method: hide()
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
});
timeObj.show();
timeObj.hide();
Method: hide()
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
});
timepickerObject.appendTo('#element');
timepickerObject.show();
timepickerObject.hide();
Show Method: show()
Copied to clipboard
var timeObj = new ej.TimePicker($("#timepicker"), {
});
timeObj.show();
timeObj.hide();
Method: show()
Copied to clipboard
let timepickerObject: TimePicker = new TimePicker({
});
timepickerObject.appendTo('#element');
timepickerObject.show();