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

Scheduler in Resource View


Hi,
       I have two tables Resources and Booking.

      Resource Table has the following fields.

      Id       Name

      1         Discussion Room
      2         Learning Room

     and the booking table is used to book an appointment. The fields for the booking table are as follows.

    BookingId    ResourceId     Start time          End time          

     I need to get the resource from the resource table and bind it to schedule control like.


                          Discussion Room            Learning Room

12.00 AM      


1.00 AM


2.00 AM


3.00 AM

    when book an appointment,  i need to get the resourceid and persist in the booking table.

    Could give me the  sample source for this scenario.


Thanks
Saravanan .T



      


   


1 Reply

SK Sarath Kumar P K Syncfusion Team September 25, 2015 09:36 AM UTC

Hi Saravanan,

Thanks for contacting Syncfusion support.

We have prepared a schedule sample to meet your requirement which can be downloaded from the following location.
http://www.syncfusion.com/downloads/support/forum/120542/ze/ScheduleMultipleResource1236107123

In the above sample we have used two database table, named Booking for appointments and Resources for resource data. We bind those data value in schedule as shown in the following code example:
<code>
[index.cshtml]

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

     .Width("100%")

     .Height("525px")

         .Resources(res => { res.Field("ResourceId").Title("Owner").Name("Owners").AllowMultiple(true).ResourceSettings(flds => flds.Datasource(ds => ds.URL("/Home/GetResources")).Text("Text").Id("Id").Color("Color")).Add(); })     //Bind the resource data value to schedule

            .Group(gr =>

            {

                gr.Resources(ViewBag.Resources);

            })

     .AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Home/GetData").CrudURL("/Home/Batch").Adaptor("UrlAdaptor"))   //Bind the appointments data to get and also perform CRUD operation

     .Id("BookingId")

     .StartTime("StartTime")

     .EndTime("EndTime")

     .ResourceFields("ResourceId")            //Bind the appointmentSetting field for resource to process the resource value

     .StartTimeZone("StartTimeZone")

     .EndTimeZone("EndTimeZone"))
)

[HomeController.cs]

        public JsonResult GetData()          //Method to get the appointments data

        {

            IEnumerable data = new ScheduleDataDataContext().Bookings.Take(100);

            return Json(data, JsonRequestBehavior.AllowGet);

        }


        public JsonResult GetResources()      //Method to get the resources data

        {

            IEnumerable data = new ScheduleDataDataContext().Resources.Take(100);

            return Json(data, JsonRequestBehavior.AllowGet);
        }
</code>


Regards,
Sarath Kumar P K

Loader.
Up arrow icon