Use custom class instead of Appointment class

Hello,

Is there any way I can use a custom class instead of the appointment class for a schedule control?

Or at least to extend current appointment class properties?


Below is my schedule, but it doesn't work if the object that comes in the model has for example for subject a field called StartDate instead of StartTime. I also need to add a bunch of other properties, but i cannot find how ... 

<div class="container-fluid">

    @(Html.EJ().Schedule("Schedule")

          .Width("100%")

          .Height("525px")

          .Views(views) 

          .CurrentView(CurrentView.Agenda) 

          .CurrentDate(new DateTime(2018, 8, 20))

          .FirstDayOfWeek(DayOfWeek.Monday)

          .IsResponsive(true)

          .ContextMenuSettings(contextMenu => contextMenu.Enable(false))

          .ScheduleClientSideEvents(e => e.AppointmentWindowOpen("onAppointmentWindowOpen").QueryCellInfo("OnCheckInfo"))

          .ShowWeekend(false)

          .AppointmentSettings(fields => fields.Datasource(Model)

              .Id("Id")

              .Subject("Name")

              .StartTime("StartDate")

              .EndTime("EndDate")

              .Description("Description")

              .AllDay("IsAllDay")

              .Recurrence("IsRecurrence")

              .RecurrenceRule("RecurrenceRule"))

          )

</div>


Regards,

Cristina


3 Replies

AA Arulraj A Syncfusion Team August 27, 2018 06:44 AM UTC

Hi Cristina, 
 
Thanks for contacting Syncfusion support. 
 
We have prepared the sample with the shared code example along with the custom class called “DataSource”, in which we have defined the Schedule control related properties along with some custom properties and it can be downloaded from the following location. 
 
Schedule control agenda view display: 
 
 
 
Please refer to the following custom class used in the above sample. 
public class DataSource 
        { 
            private int id; 
            private string name; 
            private string description; 
            private DateTime startDate; 
            private DateTime endDate; 
            private bool isAllDay; 
            private bool isRecurrence; 
            private string recurrenceRule; 
            // addinal fields 
            private DateTime orderDate; 
            private bool isDelivered; 
            private string productName; 
            private int customerMobileNo; 
            public DataSource(int id, string name, string description, DateTime startDate, DateTime endDate, bool isAllDay, bool isRecurrence, string recurrenceRule, DateTime orderDate, bool isDelivered, string productName, int customerMobileNo) 
            { 
                this.id = id; 
                this.name = name; 
                this.description = description; 
                this.startDate = startDate; 
                this.endDate = endDate; 
                this.isAllDay = isAllDay; 
                this.isRecurrence = isRecurrence; 
                this.recurrenceRule = recurrenceRule; 
                // addional fields 
                this.orderDate = orderDate; 
                this.isDelivered = isDelivered; 
                this.productName = productName; 
                this.customerMobileNo = customerMobileNo; 
            } 
            public int Id 
            { 
                get { return id; } 
                set { id = value; } 
            } 
            public string Name 
            { 
                get { return name; } 
                set { name = value; } 
            } 
            public string Description 
            { 
                get { return description; } 
                set { description = value; } 
            } 
            public DateTime StartDate 
            { 
                get { return startDate; } 
                set { startDate = value; } 
            } 
            public DateTime EndDate 
            { 
                get { return endDate; } 
                set { endDate = value; } 
            } 
            public bool IsAllDay 
            { 
                get { return isAllDay; } 
                set { isAllDay = value; } 
            } 
            public bool IsRecurrence 
            { 
                get { return isRecurrence; } 
                set { isRecurrence = value; } 
            } 
            public string RecurrenceRule 
            { 
                get { return recurrenceRule; } 
                set { recurrenceRule = value; } 
            } 
 
            // addional fields 
 
            public DateTime OrderDate 
            { 
                get { return orderDate; } 
                set { orderDate = value; } 
            } 
            public bool IsDelivered 
            { 
                get { return isDelivered; } 
                set { isDelivered = value; } 
            } 
            public string ProductName 
            { 
                get { return productName; } 
                set { productName = value; } 
            } 
            public int CustomerMobileNo 
            { 
                get { return customerMobileNo; } 
                set { customerMobileNo = value; } 
            } 
        } 
 
Kindly try with the above sample if you still face the same problem at your end, revert us with some more information like controller page code or share your custom class details or reproduce the issue in the above shared sample. The information provided by you will be more helpful for us to analyze your reported scenario further and provide you the possible solution. 

Arulraj A 



CP Cristina Pelivan August 28, 2018 02:59 PM UTC

Hello, 

Thank you. Seems like it's working now.  One more question though. Is there any option to let the user decide the color of the appointment? Does the class has this kind of property?

Thank you.


AA Arulraj A Syncfusion Team August 29, 2018 11:56 AM UTC

Hi Cristina, 
 
Yes, it is possible to decide the color of appointment by making use of the ‘categorization’ property. we suggest you to refer the following online sample link. 
 
 
Please try with the above sample and UG links and let us know if you need any further assistance on this. 
 
Regards, 
Arulraj A 


Loader.
Up arrow icon