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

Get Data from Sql server database and bind to schedule control

Hi,
       I have used the below code to get the data.

       public ActionResult GetData()
        {
            IEnumerable data = new ScheduleDataContext().DefaultSchedules.Take(2);
            return Json(data, JsonRequestBehavior.AllowGet);
        }

     I have placed the GetData method in the controller named Schedule.

    And the .cshtml code is as follows.

    $(function () {

     var localServ = "/Schedule/GetData";

     var dManager = ej.DataManager({

     url: localServ,

     crudUrl: "/Schedule/CRUD"                // Here you have to pass the post action name for the crud operation

     });

     dManager.adaptor = new ej.UrlAdaptor();

     var query = ej.Query().from("DefaultSchedules");//.select("id,Subject,Location,StartTime,EndTime,Description,Categorize,AllDay");

$("#Schedule1").ejSchedule({

     enableAppointmentNavigation: false,

     currentDate: new Date(2015, 9, 22),

     appointmentSettings: {

     dataSource: dManager,

     tableName: "DefaultSchedules",

     query: query,

     id: "Id",

     subject: "Subject",

     //location: "Location",

     description: "Description",

     startTime: "StartTime",

     endTime: "EndTime",

     allDay: "AllDay",

     recurrence: "Recurrence",

     recurrenceRule: "RecurrenceRule"

     }

 });

});

     @(Html.EJ().Schedule("Schedule1")
     .Width("100%")
     .Height("525px")
     .AppointmentSettings(fields => fields.Datasource(ds => ds.URL("Schedule/GetData").Adaptor("UrlAdaptor"))
     .Id("Id")
     .Subject("Subject")
     .Description("Description")
     .StartTime("StartTime")
     .EndTime("EndTime")
     .AllDay("AllDay")
     .Recurrence("Recurrence")
     .RecurrenceRule("RecurrenceRule"))
     )

when i run the application, the browser shows the json data as below

[{"Id":1,"Subject":"Test Appointment","Description":"Test Appointment","StartTime":"\/Date(1442910600000)\/","EndTime":"\/Date(1442914200000)\/","AllDay":false,"Recurrence":false,"RecurrenceRule":"Test"}]
but the scheduler control is not visible. could you please tell me what changes needs to be done to get the appointment data bind to scheduler control ?




  

1 Reply

SK Sarath Kumar P K Syncfusion Team September 23, 2015 10:13 AM UTC

Hi Saravanan,

Thanks for contacting Syncfusion support.

We have analyzed your reported issue with your code example. We suspect that you don’t have any appointments on the date schedule render initially. We request you to check the appointment data for a particular date in scheduler and to see the appointments. We have prepared a schedule sample to get the data from SQL and bind it to scheduler and it can be downloaded from the following location:
http://www.syncfusion.com/downloads/support/forum/120516/ze/ScheduleCRUD-1851262232

In the above sample we have appointments on date 10, 11, 12 and 14 August 2015.

Regards,
Sarath Kumar P K

Loader.
Up arrow icon