Add custom field not using editer in scheduler

Hi Guys,

I am trying to add custom field example hours worked to an appointment, my appointments are read only so i want to add hours from data passed to scheduler,
i an using core 3.1 and Entity Framework and Microsoft SQL.

Summary I want to add custom field to appear last in scheduler appointment

Please note am using ajax call to populate schedule data need javascript to create custom field

 public class AppointmentData
    {
        public int Id { get; set; }
        public string Subject { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
        public bool IsAllDay { get; set; }
        public string CategoryColor { get; set; }
        public string HoursWorked { get; set; }
        
    }

example  Task : Coding

Date Time

Hours Worked 8:00:00

please see  image on image Hour Worked to be last field

Regards

Edmund Herbert


Attachment: Task_b333de92.zip

4 Replies 1 reply marked as answer

RV Ravikumar Venkatesan Syncfusion Team November 9, 2020 11:56 AM UTC

Hi Edmund, 

Greetings from Syncfusion support. 

We have validated your reported query at our end. We suspect that your requirement is to add the custom field “HoursWorked” value to the appointment. We have achieved your requirement with the help of the eventTemplate of the Schedule like the below code. We have prepared a sample for your reference which can be available below. We have added a custom field “HoursWorked” on the DB. When connecting the Schedule sample with the service sample. The HoursWorked field value available in each appointment is showed with the help of the eventTemplate

[Index.cshtml] 
<ejs-schedule id="schedule" width="100%" height="550" readonly="true"> 
    <e-schedule-eventsettings template="@ViewBag.template"> 
    </e-schedule-eventsettings> 
</ejs-schedule> 


[HomeController.cs] 
        public IActionResult Index() 
        { 
            ViewBag.template = "<div class='template-wrap' ><div class='subject' >${Subject}</div><div class='time' >Time: ${getTimeString(data.StartTime)} - ${getTimeString(data.EndTime)}</div><div class='hours'>${HoursWorked}</div></div>"; 
            return View(); 
        } 


Kindly try the above sample and get back to us if you need any further assistance. 

Regards, 
Ravikumar Venkatesan 


Marked as answer

EH Edmund Herbert November 9, 2020 01:43 PM UTC

Hi Ravikumar Venkatesan

The example you sent see attached file is missing :

 var ajax = new ej.base.Ajax('http://localhost:54738/Home/LoadData', 'Post', false); there is no Home/LoadDate in home controller

I also need  HoursWorked field I calculate hours worked and want to return to appointment string hours worked as example 8:00:00

Please help

Ok my apologies I see how you did it I have to run both apps

Thanks

Regards

Edmund Herbert

Attachment: EJ2CO1555460501_42b10507.zip


EH Edmund Herbert November 9, 2020 04:51 PM UTC

Hi Ravikumar,

Thanks for example exactly what I needed.

Regards

Edmund Herbert


NR Nevitha Ravi Syncfusion Team November 10, 2020 05:36 AM UTC

Hi Edmund, 

You are most welcome 😊, please get back to us for further assistance. 

Regards, 
Nevitha 


Loader.
Up arrow icon