- Home
- Forum
- JavaScript - EJ 2
- How to customize an appointment by changing the color and adding custom fields in subject
How to customize an appointment by changing the color and adding custom fields in subject
I have looked at all the examples but i dont understand setting up in javacript. Can you give me a simple example to change the color of an appointment and another simple example to display a custom field in addition to the subject in the appointment in javascript environment
SIGN IN To post a reply.
9 Replies
1 reply marked as answer
PN
Praveenkumar Narasimhanaidu
Syncfusion Team
November 30, 2020 12:40 PM UTC
Hi Gilles,
Greetings from Syncfusion support.
Q1: Setting appointment color.
We can set the color to the appointments by using customizing the events. We have prepared a sample for your reference using eventRendered event which can be viewed from following link.
[index.ts]
|
eventRendered: (args: EventRenderedArgs) => {
let categoryColor: string = args.data.CategoryColor as string;
if (!args.element || !categoryColor) {
return;
}
if (scheduleObj.currentView === "Agenda") {
(args.element
.firstChild as HTMLElement).style.borderLeftColor = categoryColor;
} else {
args.element.style.backgroundColor = categoryColor;
}
} |
Please refer other ways to customize the events using the following link.
https://ej2.syncfusion.com/documentation/schedule/appointments/?no-cache=1#appointment-customization
Q2: custom field in addition to the subject.
We can achieve your requirement by using template option in which you can access all the appointment fields. We have prepared a sample for your reference which can viewed from following link.
[index.html]
|
<script id="apptemplate" type="text/x-template">
<div class="template-wrap" style="background:${SecondaryColor}">
<div class="subject">${Subject}</div>
<div class="description">${Description}</div>
</div>
</script> |
Kindly try the above solutions and get back to us if you need any further assistance.
Regards,
Praveenkumar.
GI
Gilles
December 4, 2020 10:39 AM UTC
Sorry, but we work in .js environment not .ts environment
could you translate your sample in .js
Thanks a lot
NR
Nevitha Ravi
Syncfusion Team
December 4, 2020 12:57 PM UTC
Hi Gilles,
Thanks for your update.
Please find the following sample for your requirement and get back to us with the previously requested details if you face any problem,
Regards,
Nevitha
Marked as answer
GI
Gilles
December 4, 2020 06:18 PM UTC
it's work !
but how to format the {StartTime} to see just hour and minutes (hh:mm)?
<script id="apptemplate" type="text/x-template">
<div class="template-wrap">
<div class="e-subject">${Subject}</div>
<div class="e-subject">${Buzzee_Content}</div>
<div class="e-time">${StartTime}</div>
<div class="e-subject">${Description}</div>
</div>
</script>
<div class="template-wrap">
<div class="e-subject">${Subject}</div>
<div class="e-subject">${Buzzee_Content}</div>
<div class="e-time">${StartTime}</div>
<div class="e-subject">${Description}</div>
</div>
</script>
NR
Nevitha Ravi
Syncfusion Team
December 7, 2020 04:50 AM UTC
Hi Gilles,
Thanks for your update.
You can format the date in the event template with the help of internationalization, please refer to the following sample and UG.
var instance = new ej.base.Internationalization();
window.getTimeString = function(value) {
return instance.formatDate(value, { skeleton: "hm" });
};
<script id="apptemplate" type="text/x-template">
<div class="template-wrap" style="background:${SecondaryColor}">
<div class="subject">${Subject}</div>
<div class="time">Time: ${getTimeString(data.StartTime)} - ${getTimeString(data.EndTime)}</div>
</div>
</script>
Please try the above sample and get back to us if you need any further assistance.
Regards,
Nevitha
GI
Gilles
December 8, 2020 11:30 AM UTC
Perfect ! Thanks
NR
Nevitha Ravi
Syncfusion Team
December 8, 2020 12:22 PM UTC
Hi Gilles,
You are most welcome..! Please get back to us if you need any further assistance.
Regards,
Nevitha
GI
Gilles
December 21, 2020 02:47 PM UTC
Despite the loading of the fr-ch language and the change of culture.
The code instance.formatDate(value, { skeleton: "hm" }); display 08:00AM 4:00 PM
How to display 08:00 16:00
Regards
NR
Nevitha Ravi
Syncfusion Team
December 22, 2020 05:30 AM UTC
Hi Gilles,
Thanks for your update.
You can get the 24 hour format with the below code please refer to the following sample.
window.getTimeString = function(value) {
return instance.formatDate(value, { skeleton: "Hm" });
};
Also, you can refer the previously shared UG to set different date and time formats.
Regards,
Nevitha
SIGN IN To post a reply.
- 9 Replies
- 3 Participants
- Marked answer
-
GI Gilles
- Nov 27, 2020 02:13 PM UTC
- Dec 22, 2020 05:30 AM UTC