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.
Unfortunately, activation email could not send to your email. Please try again.

Javascript error when trying to return data for a schedule

Thread ID:

Created:

Updated:

Platform:

Replies:

128818 Feb 10,2017 11:34 AM Feb 13,2017 01:05 AM ASP.NET MVC 1
loading
Tags: Schedule
Cornel Amarandei
Asked On February 10, 2017 11:34 AM

Hi,

I have this error when trying to return data for a schedule: "Uncaught TypeError: Cannot read property 'StartTime' of undefined" in ej.web.all.min.js.

My controller action looks like this:

public JsonResult Batch(EditParams param)
        {
            var data = new List<ScheduleData>();
            data.Add(new ScheduleData() { Subject = "Testing", StartTime = DateTime.Now, EndTime = DateTime.Now.AddDays(3), AllDay = true, Owner = 1 });
            return Json(data.AsEnumerable(), JsonRequestBehavior.AllowGet);
        }

The class ScheduleData looks like this:

public class ScheduleData
    {
        public int Id;

        public string Subject;

        public string Location;

        public System.DateTime StartTime;

        public System.DateTime EndTime;

        public string Description;

        public System.Nullable<int> Owner;

        public System.Nullable<int> Priority;

        public System.Nullable<byte> Recurrence;
        
        public string Categorize;
       
        public System.Nullable<bool> AllDay;        
    }

And the Schedule code is this:

 @(Html.EJ().Schedule("Schedule1")
    .Width("100%")
    .Height("525px")
    .CellWidth("40px")
    .Orientation(Syncfusion.JavaScript.Orientation.Horizontal)
    .ShowCurrentTimeIndicator(false)
    .CurrentDate(DateTime.Now)
    .Views(views)
    //.AllowDragDrop(true)
    //.ShowAllDayRow(true)
    .Resources(res => { res.Field("OwnerId").Title("Owner").Name("Owners").AllowMultiple(true).ResourceSettings(flds => flds.Datasource((IEnumerable<object>)ViewBag.Owners).Text("text").Id("id").Color("color")).Add(); })
    .Group(gr => { gr.Resources(ViewBag.Resources); })
    //.AppointmentSettings(fields => fields.Datasource(ViewBag.datasource)
    .AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Projects/GetData").CrudURL("/Projects/Batch"))
        .Id("Id")
        .Subject("Subject")
        .StartTime("StartTime")
        .EndTime("EndTime")
        .Description("Description")
        .AllDay("true")
        .Recurrence("Recurrence")
        .RecurrenceRule("RecurrenceRule"))
    )

The error comes after I try to insert a new appoitment, so after the return from the Batch action.

Thank you!

Karthigeyan Krishnamurthi [Syncfusion]
Replied On February 13, 2017 01:05 AM

Hi Cornel,   
  
Thank you for contacting Syncfusion Support.   
  
We suspect that appointment was not saved properly in database, which could have caused the issue. We have prepared a CRUD sample with the provided code example, which can be downloaded from:   
  
In the above sample, when an appointment is added/edited/deleted, it will be reflected in the database too. Kindly refer to the below code example used in the sample.   
<Code> 
public JsonResult Batch(EditParams param) 
        { 
            if (param.action == "insert" || (param.action == "batch" && param.added != null))          // this block of code will execute while inserting the appointments 
            { 
                 
            } 
            if (param.action == "remove" || param.deleted != null)                                        // this block of code will execute while removing the appointment 
            { 
                
            } 
            if ((param.action == "batch" && param.changed != null) || param.action == "update")   // this block of code will execute while updating the appointment 
            { 
                
            } 
            IEnumerable data = new DataClasses1DataContext().ScheduleDatas.Take(500); // nw.Appointment.Take(5); 
            return Json(data, JsonRequestBehavior.AllowGet); 
        } 
</Code> 
 
Regards, 
Karthigeyan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;