Search results

Migration from Essential JS 1 in Angular DatePicker component

26 Oct 2021 / 12 minutes to read

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

Date Selection

Behavior API in Essential JS 1 API in Essential JS 2
Setting the value Property: value
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" value="5/5/2019"/>
Property: value
Copied to clipboard
<ejs-datepicker id="datepicker" value='5/5/2019'></ejs-datepicker>

Date Format

Behavior API in Essential JS 1 API in Essential JS 2
Display date format Property: dateFormat
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" dateFormat='yyyy/MM/dd'/>
Property: format
Copied to clipboard
<ejs-datepicker id="datepicker" format="yyyy-MM-dd"></ejs-datepicker>
Day header format Property: dayHeaderFormat
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" dayHeaderFormat="long"/>
Not Applicable

Calendar Views

Behavior API in Essential JS 1 API in Essential JS 2
Start view Property: startLevel
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" startLevel="year"/>
Property: start
Copied to clipboard
<ejs-datepicker id="datepicker" start="Decade"></ejs-datepicker>
Depth view Property: depthLevel
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" depthLevel="year"/>
Property: depth
Copied to clipboard
<ejs-datepicker id="datepicker" depth="Year"></ejs-datepicker>

Date Range

Behavior API in Essential JS 1 API in Essential JS 2
Minimum date Property: minDate
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" minDate="5/5/2019"/>
Property: min
Copied to clipboard
<ejs-datepicker id="datepicker" min="6/6/2019"></ejs-datepicker>
Maximum date Property: maxDate
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" maxDate="5/5/2019"/>
Property: max
Copied to clipboard
<ejs-datepicker id="datepicker" max="6/6/2019"></ejs-datepicker>

Disabled Dates

Behavior API in Essential JS 1 API in Essential JS 2
Block-out dates Property: blackoutDates
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [blackoutDates]='blackoutDates'/>
Copied to clipboard
blackoutDates : Object = [new Date(2016, 4, 10), new Date(2016, 4, 15), new Date(2016, 4, 20), new Date(2016, 4, 22), new Date(2016, 5, 12), new Date(2016, 5, 24)]
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" (renderDayCell)="disableDate($event)"></ejs-datepicker>
Copied to clipboard
public disableDate(args) {
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
<input type="text" ej-datepicker id="datepicker" cssClass="gradient-lime"/>
Property: cssClass
Copied to clipboard
<ejs-datepicker id="datepicker"  cssClass='gradient-lime'></ejs-datepicker>
Event callback for each cell creation Not Applicable Event: renderDayCell
Copied to clipboard
<ejs-datepicker id="datepicker" (renderDayCell)="onRenderCell($event)"></ejs-datepicker>
Copied to clipboard
public onRenderCell(args:any) {/** code block */}
Show/Hide the today button Property: showFooter
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [showFooter]="false"/>
Property: showTodayButton
Copied to clipboard
<ejs-datepicker id="datepicker" [showTodayButton]="false"></ejs-datepicker>
Show/Hide the other month dates Property: showOtherMonths
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [showOtherMonths]="false"/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker"></ejs-datepicker>
Copied to clipboard
.e-datepicker .e-calendar .e-content tr.e-month-hide, .e-datepicker .e-calendar .e-content td.e-other-month > .e-day {
    visibility: none;
   }

.e-datepicker .e-calendar .e-content td.e-month-hide, .e-datepicker .e-calendar .e-content td.e-other-month {
    pointer-events: none;
    touch-action: none;
}
Show/Hide the disabled date Property: showDisabledRange
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [showDisabledRange]="false" [blackoutDates]='blackoutDates'/>
Copied to clipboard
blackoutDates : Object = [new Date(2016, 4, 10), new Date(2016, 4, 15), new Date(2016, 4, 20), new Date(2016, 4, 22), new Date(2016, 5, 12), new Date(2016, 5, 24)]
Not Applicable
Show/Hide the popup button Property: showPopupButton
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [showPopupButton]="false"/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" #dateObj (focus)="onFocus($event)"></ejs-datepicker>
Copied to clipboard
@ViewChild("dateObj") dateObj: DatePickerComponent;

public onFocus(args:any) {
this.dateObj.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
<input type="text" ej-datepicker id="datepicker" [showRoundedCorner]="true"/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" #dateObj cssClass='e-customStyle'></ejs-datepicker>
Copied to clipboard
.e-control-wrapper.e-customStyle.e-date-wrapper.e-input-group {
border-radius: 4px;
}
Skip a month Property: stepMonths
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [stepMonths]="3"/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" #dateObj value='5/5/2019' (open)="onOpen($event)"></ejs-datepicker>
Copied to clipboard
@ViewChild("dateObj") dateObj: DatePickerComponent;
public onOpen(args:any){
this.dateObj.navigateTo('Year', new Date("03/18/2028"));
}
Show/Hide the tooltip Property: showTooltip
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [showTooltip]="false"/>
Not Applicable
Today button text Property: buttonText
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" buttonText="Now"/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" locale='de'></ejs-datepicker>
Copied to clipboard
L10n.load({
'de': {
    'datepicker': { placeholder: 'Wählen Sie ein Datum aus',
    `today: 'heute' }
}
});
Display inline Property: displayInline
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [displayInline]='true'/>
Not Applicable
Enable/Disable the animation Property: enableAnimation
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [enableAnimation]='false'/>
Not Applicable
Highlight dates Property: highlightSection
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" highlightSection='month'/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" (renderDayCell)='highlightDate($event)'></ejs-datepicker>
Copied to clipboard
public highlightDate(args:any) {
if (args.date.getDate() === 10) {
    args.element.classList.add('e-highlightweekend');
}
}
Copied to clipboard
.e-highlightweekend {
background-color: #cfe9f3;
}
Highlight weekend Property: highlightWeekend
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [highlightWeekend]='true'/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" (renderDayCell)='highlightDate($event)'></ejs-datepicker>
Copied to clipboard
public highlightDate(args:any) {
if (args.date.getDay() === 0 || args.date.getDay() === 6) {
    args.element.classList.add('e-highlightweekend');
}
}
Copied to clipboard
.e-highlightweekend {
background-color: #cfe9f3;
}
Tooltip format Property: tooltipFormat
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" tooltipFormat='dd/MM/yyyy'/>
Not Applicable
Special dates Property: specialDates
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [specialDates]='specialdate'/>
Copied to clipboard
specialdate: Object = [ { date: new Date(), tooltip: "In Australia" }]
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" (renderDayCell)='customDates($event)' value='5/5/2017'></ejs-datepicker>
Copied to clipboard
public customDates(args:any) {
 let span: HTMLElement;
if (args.date.getDate() === 10) {
    span = document.createElement('span');
    span.setAttribute('class', 'e-icons highlight');
    args.element.firstElementChild.setAttribute('title', 'Birthday !');
    args.element.setAttribute('title', 'Birthday !');
    args.element.setAttribute('data-val', 'Birthday !');
    args.element.appendChild(span);
}
}
FocusIn event Event: focusIn
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (focusIn)='onFocus($event)'/>
Copied to clipboard
public onFocus(e:any) {
/** code block */
}
Event: focus
Copied to clipboard
<ejs-datepicker id="datepicker" (focus)='onFocus($event)'></ejs-datepicker>
Copied to clipboard
public onFocus(args:any) {
/** code block */  
}
FocusOut event Event: focusOut
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (focusOut)='onFocus($event)'/>
Copied to clipboard
public onFocus(e:any) {
/** code block */
}
Event: blur
Copied to clipboard
<ejs-datepicker id="datepicker" (blur)='onBlur($event)'></ejs-datepicker>
Copied to clipboard
public onBlur(args:any) {
/** code block */  
}
FocusIn method Not Applicable Method: focusIn()
Copied to clipboard
<ejs-datepicker id="datepicker" #dateObj (created)='create($event)'></ejs-datepicker>
Copied to clipboard
@ViewChild("dateObj") dateObj : DatePickerComponent;
public create(args:any){
this.dateObj.focusIn();
}
FocusOut method Not Applicable Method: focusOut()
Copied to clipboard
<ejs-datepicker id="datepicker" #dateObj (created)='create($event)'></ejs-datepicker>
Copied to clipboard
@ViewChild("dateObj") dateObj : DatePickerComponent;
public create(args:any){
this.dateObj.focusIn();
this.dateObj.focusOut();
}
Prevent popup close Not Applicable Event: Close
Copied to clipboard
<ejs-datepicker id="datepicker"  (close)='onClose($event)'></ejs-datepicker>
Copied to clipboard
public onClose(args) {
/*Triggers when the popup gets close*/
args.cancel = true;
}
Prevent popup open Not Applicable Event: Open
Copied to clipboard
<ejs-datepicker id="datepicker" (open)='onOpen($event)'></ejs-datepicker>
Copied to clipboard
public onOpen(args:any) {
/*Triggers when the popup gets close*/
args.cancel = true;
}

Accessibility

Behavior API in Essential JS 1 API in Essential JS 2
Enable/Disable the RTL Property: enableRTL
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [enableRTL]='true'/>
Property: enableRtl
Copied to clipboard
<ejs-datepicker id="datepicker" [enableRtl]='true'></ejs-datepicker>

Persistence

Behavior API in Essential JS 1 API in Essential JS 2
Enable/Disable the persistence Property: enablePersistence
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [enablePersistence]='true'/>
Property: enablePersistence
Copied to clipboard
<ejs-datepicker id="datepicker" [enablePersistence]='true'></ejs-datepicker>

Validation

Behavior API in Essential JS 1 API in Essential JS 2
Validation rules Property: validationRules
Copied to clipboard
<input type="text" ej-datepicker id="timePicker"  [validationRules]="validationRules"/>
Copied to clipboard
validationRules:Object;
constructor(){
this.validationRules = {required:true};
}
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" floatLabelType='Always'></ejs-datepicker>
Copied to clipboard
let options: FormValidatorModel = {
rules: {
    'datepicker': { required: [true, "Value is required"] } }};
    this.formObject = new FormValidator('#form-element', options);
Validation message Property: validationMessage
Copied to clipboard
<input type="text" ej-datepicker id="timePicker"  [validationRules]="validationRules" [validationMessage]="validationMessage"/>
Copied to clipboard
validationRules:Object;
validationMessage:Object;
constructor(){
this.validationMessage = {required: "Required Date value"};
this.validationRules = {required:true};
}
Can be achieved by
Copied to clipboard
<ejs-datepicker #datepicker id="datepicker" floatLabelType='Always'></ejs-datepicker>
Copied to clipboard
let options: FormValidatorModel = {
rules: {
    'datepicker': {
                required: [true, "Value is required"]
            }
        },
        customPlacement: (inputElement: HTMLElement, errorElement: HTMLElement) => {
            inputElement.parentElement.parentElement.appendChild(errorElement);
        }
    };
this.formObject = new FormValidator('#form-element', options);

Common

Behavior API in Essential JS 1 API in Essential JS 2
Width Property: width
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" width='300px'/>
Property: width
Copied to clipboard
<ejs-datepicker id="datepicker" width='300px'></ejs-datepicker>
Readonly Property: readonly
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [readOnly]='true'/>
Property: readonly
Copied to clipboard
<ejs-datepicker id="datepicker" [readonly]='true'></ejs-datepicker>
Show/Hide the clear button Not Applicable Property: showClearButton
Copied to clipboard
<ejs-datepicker id="datepicker" [showClearButton]='false'></ejs-datepicker>
Height Property: height
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" height='50px'/>
Can be achieved by
Copied to clipboard
<ejs-datepicker id="datepicker" cssClass='e-custom-style'></ejs-datepicker>
Copied to clipboard
.e-control-wrapper.e-custom-style.e-date-wrapper.e-input-group {
height: 35px;
}
Html attributes Property: HtmlAttributes
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [htmlAttributes] = 'htmlAttributes'/>
Copied to clipboard
htmlAttributes : Object = {required:"required"}
Not Applicable
Enable/Disable the week number Property: weekNumber
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [weekNumber] = 'true'/>
Property: weekNumber
Copied to clipboard
<ejs-datepicker id="datepicker" [weekNumber]='true'></ejs-datepicker>
Watermark text Property: watermarkText
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" watermarkText= 'Enter a date'/>
Property: placeholder
Copied to clipboard
<ejs-datepicker id="datepicker" placeholder='Enter Date'></ejs-datepicker>
Disable/Enable Property: enabled
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [enabled]= 'false'/>
Property: enabled
Copied to clipboard
<ejs-datepicker id="datepicker" [enabled]='false'></ejs-datepicker>
Disable the DatePicker Method: disable()
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (create)= 'onCreate($event)'/>
Copied to clipboard
public onCreate(e:any) {
var dateObject = $("#datepicker").data("ejDatePicker");
dateObject.disable();
}
Not Applicable
Enable the DatePicker Method: enable()
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (create)= 'onCreate($event)'/>
Copied to clipboard
public onCreate(e:any) {
var dateObject = $("#datepicker").data("ejDatePicker");
dateObject.enable();
}
Not Applicable
Enable/Disable the textBox editing Property: AllowEdit
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [allowEdit]= 'true'/>
Property: AllowEdit
Copied to clipboard
<ejs-datepicker id="datepicker" [allowEdit]='false'></ejs-datepicker>
zIndex Not Applicable Property: zIndex
Copied to clipboard
<ejs-datepicker id="datepicker" zIndex="2000"></ejs-datepicker>
Specify the placeholder text behavior Not Applicable Property: floatLabelType
Copied to clipboard
<ejs-datepicker id="datepicker" placeholder='Enter date' floatLabelType='Auto'></ejs-datepicker>

Globalization

Behavior API in Essential JS 1 API in Essential JS 2
Locale Property: Locale
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" locale="en-US"/>
Property: locale
Copied to clipboard
<ejs-datepicker id="datepicker" locale='en'></ejs-datepicker>
First day of week Property: startDay
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [startDay]="4"/>
Property: firstDayOfWeek
Copied to clipboard
<ejs-datepicker id="datepicker" [firstDayOfWeek]='5'></ejs-datepicker>

Strict Mode

Behavior API in Essential JS 1 API in Essential JS 2
Strict mode Property: enableStrictMode
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [enableStrictMode]="true"/>
Property: strictMode
Copied to clipboard
<ejs-datepicker id="datepicker" min="5/5/2019" max="6/6/2019" value="7/7/2019" [strictMode]='true'></ejs-datepicker>

Open and Close

Behavior API in Essential JS 1 API in Essential JS 2
Close Event: Close
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (close)="onClose($event)"/>
Copied to clipboard
public onClose(e:any) { /** code block */ }
Event: Close
Copied to clipboard
<ejs-datepicker id="datepicker" (close)="onClose($event")></ejs-datepicker>
Copied to clipboard
public onClose(args:any) { /** code block */ }
Hide Method: hide()
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (create)="onCreate($event")/>
Copied to clipboard
public onCreate(e:any) {
var dateObject = $("#datepicker").data("ejDatePicker");
dateObject.show();
dateObject.hide();
}
Method: hide()
Copied to clipboard
<ejs-datepicker id="datepicker" #dateObj (created)="onCreate($event")></ejs-datepicker>
Copied to clipboard
@ViewChild("dateObj") dateObj: DatePickerComponent;
public onCreate(args:any){
this.dateObj.show();
this.dateObj.hide();
}
Open Event: Open
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (open)="onOpen($event)"/>
Copied to clipboard
public onOpen(e:any) { /** code block */ }
Event: Open
Copied to clipboard
<ejs-datepicker id="datepicker" (open)="onOpen($event")></ejs-datepicker>
Copied to clipboard
public onOpen(args:any) { /** code block */ }
Show Method: show()
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (create)="onCreate($event")/>
Copied to clipboard
public onCreate(e:any) {
var dateObject = $("#datepicker").data("ejDatePicker");
dateObject.show();
}
Method: show()
Copied to clipboard
<ejs-datepicker id="datepicker" #dateObj (created)="onCreate($event")></ejs-datepicker>
Copied to clipboard
@ViewChild("dateObj") dateObj: DatePickerComponent;
public onCreate(args:any){
this.dateObj.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
<ejs-datepicker id="datepicker" #dateObj value='5/5/2019' (open)="onOpen($event)"></ejs-datepicker>
Copied to clipboard
@ViewChild("dateObj") dateObj: DatePickerComponent;
public onOpen(args:any){
this.dateObj.navigateTo('Year', new Date("03/18/2028"));
}
Navigation callback Event: Navigate
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" (navigate)="onNavigate($event")/>
Copied to clipboard
public onNavigate(e:any) {/** code block */ }
Event: Navigated
Copied to clipboard
<ejs-datepicker id="datepicker" (navigated)="onNavigated($event)"></ejs-datepicker>
Copied to clipboard
public onNavigated(args:any) {/** code block */ }
Enable/Disable the drill down Property: allowDirllDown
Copied to clipboard
<input type="text" ej-datepicker id="datepicker" [allowDirllDown]="true")/>
Not Applicable