The DateTimePicker is available for UI customization that can be achieved by using available properties and events in the component.
The DateTimePicker is available for UI customization based on your application requirements.
It can be achieved by using renderDayCell
event that provides an option to customize each day cell on rendering.
The following example disables the weekends of every month by using renderDayCell
event.
import { Component } from "@angular/core";
import { DateTimePickerComponent } from "@syncfusion/ej2-angular-calendars";
@Component({
selector: 'app-root',
template: `<ejs-datetimepicker placeholder='Select a date and time' (renderDayCell)='onRenderCell($event)'></ejs-datetimepicker>`
})
export class AppComponent {
onRenderCell(args) {
/*Apply selected format to the component*/
if (args.date.getDay() == 0 || args.date.getDay() == 6) {
//sets isDisabled to true to disable the date.
args.isDisabled = true;
}
}
constructor() {}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { DateTimePickerModule } from '@syncfusion/ej2-angular-calendars';
import { AppComponent } from './app.component';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule,
DateTimePickerModule,
FormsModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
You can add a mandatory asterisk(*)
to placeholder and float label using .e-input-group.e-control-wrapper.e-float-input .e-float-text::after class.
{% tab template=“datetimepicker/asterisk”, isDefaultActive = “true”, sourceFiles=“app/*/.ts,asterisk.css” %}
import { Component } from "@angular/core";
@Component({
selector: 'app-root',
template: `<ejs-datetimepicker floatLabelType="auto" placeholder="Enter date"></ejs-datetimepicker>`
})
export class AppComponent {
constructor() {}
}