How to display specific field on appointments based on a condition?
This article explains the way to display the time field in an appointment based on a condition in Angular Scheduler.
Step 1: Bind the eventTemplate to change the default appointment template, as shown in the following code example.
<ng-template #eventTemplate let-data>
<div class='template-wrap'>
<div class="subject">{{data.Subject}}</div>
<div *ngIf="data.IsAllDay" class="time">{{getTimeString(data.StartTime)}} -
{{getTimeString(data.EndTime)}}</div>
</div>
</ng-template>Appointment template: https://ej2.syncfusion.com/angular/documentation/api/schedule/viewsModel/#eventtemplate
Step 2: Add the getTimeString method to retrieve the startTime and endTime in the app.component.ts file.
private instance: Internationalization = new Internationalization();
getTimeString(value: Date): string {
return this.instance.formatDate(value, { skeleton: 'hm' });
} Step 3: Add the below data source in the data.ts file.
export let resourceData: Object[] = [
{
Id: 1,
Subject: 'Testing-1',
StartTime: new Date(2018, 3, 7, 10),
EndTime: new Date(2018, 3, 7, 12),
IsAllDay: false,
IsReadonly: true,
TaskId: 2
}, {
Id: 2,
Subject: 'Testing-2',
StartTime: new Date(2018, 3, 10),
EndTime: new Date(2018, 3, 10),
IsAllDay: true,
IsReadonly: true,
TaskId: 2
}
];Step 4: Run the sample, the time field will be rendered in the appointments when the appointment is an all-day appointment as shown below.
Refer to the example from the following GitHub link.
Example – Scheduler with appointment template
Conclusion
We hope you enjoyed learning about how to display specific field on appointments
based on a condition.
You can refer to our Angular Scheduler feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular Scheduler example to understand how to create and manipulate data.
For current customers, you can check out our Document Processing Libraries from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!