We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

EventTemplate


Is there way to customize the look of an event in the scheduler?
Any Text or html-Text in EventTemplate does not work.

4 Replies

SL Steven Littleford July 18, 2019 03:23 AM UTC

Yep - mee too!

I'd like to be able to change the color of an appointment based on the underlying data within the appointment.



HB Hareesh Balasubramanian Syncfusion Team July 18, 2019 12:22 PM UTC

Hi Otmar, 

Greetings from Syncfusion Support. 

We have prepared the sample to customize the event using Template option which can be downloaded from the following link, 

    <ScheduleEventSettings DataSource="@DataSource"> 
        <Template> 
            <div>Subject: @((context as dynamic).Subject)</div> 
            <div>StartTime: @((context as dynamic).StartTime)</div> 
            <div>EndTime:  @((context as dynamic).EndTime)</div> 
        </Template> 
    </ScheduleEventSettings> 

Please try the above sample, if you have any concerns please revert us back for further assistance. 

Note: We have removed the packages for the above sample. 

Regards, 
Hareesh B 



HB Hareesh Balasubramanian Syncfusion Team July 18, 2019 12:25 PM UTC

Hi Steven, 

Greetings from Syncfusion Support. 

We have prepared the sample for your requirement using eventRendered event which can be downloaded from the following link, 
  
public void onEventRendered(EventRenderedArgs args) 
    BlogSite bsObj = JsonConvert.DeserializeObject<BlogSite>(JsonConvert.SerializeObject(args.Data)); 
    DateTime localDate = bsObj.StartTime.ToLocalTime(); 
    var hours = localDate.TimeOfDay.Hours; 
    if (hours < 12) 
    { 
        (args.Element).AddClass(this.cus1_class); 
    } 
    else if (hours >= 12 && hours < 18) 
    { 
        (args.Element).AddClass(this.cus2_class); 
    } 
    else if (hours >= 18) 
    { 
        (args.Element).AddClass(this.cus3_class); 
    } 

Please try the above sample, if you have any concerns please revert us back for further assistance. 

Note: We have removed the packages for the above sample. 

Regards, 
Hareesh B 



MA Matthew August 2, 2019 11:09 AM UTC

Hi Hareesh,

I first had a problem with having to add Microsoft.CSharp to the project and making sure to add @using Microsoft.CSharp.RuntimeBinding
I have tried adapting this and I get a javascript error in the console - this.adaptor.processQuery is not a function
I am using version 17.2.0.35, however I am using a custom model for TemplateArgs and not using th standard fields the following code should make it clear:

   
       
   
   
       
   

@code{
    public class TemplateArgs
    {
        public string Workcode { get; set; }
        public string WorkcodeName { get; set; }
        public string CandidateName { get; set; }
        public string CandidateColor { get; set; }
        public string TimesheetColor { get; set; }
        public bool AllDay { get; set; }
    }

    List _summary = new List();
    public TemplateArgs model = new TemplateArgs();

    protected override async Task OnInitAsync()
    {
        _summary = await assignmentDataService.GetAssignmentItemSummary(7000, null, null, null, null);
        StateHasChanged();
    }
}

Can you see anything wrong with what I have done?

Please ignore, I was not setting start time and end time in my data source


Loader.
Live Chat Icon For mobile
Up arrow icon