Assigning Resources to Appointments

5 posts, 0 answers
  1. Mike
    Mike avatar
    7 posts
    Member since:
    Aug 2010

    Posted 20 Sep 2010 Link to this post

    When initially loading the scheduler, how do you get the resources assigned to appointments?  I want to see the resource automatically assigned in the resource dropdown in the Edit Appointment Dialog and also see resources assigned to appointments when viewing the scheduler in grouping by resource view.

    I am using a business object for my appontments and manually assigning resources (people) from by database in the Resources collection of the Radscheduler.  I am using the  AppointmentMapping object to assigned the resourceID to the appointment.  The appointments show no relationship to resources...
    thanks,
    Mike


     

     

  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 23 Sep 2010 Link to this post

    Hi Mike,

    Please follow the available documentation concerning the topic of binding to business objects. If you still have some difficulties, feel free to contact us.

    Best wishes,
    Dobry Zranchev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mike
    Mike avatar
    7 posts
    Member since:
    Aug 2010

    Posted 23 Sep 2010 Link to this post

    Reviewing the documentation for binding to business objects....

    the statement:

    Do not set the Resources property of the AppointmentMappingInfo object to "Resources" if the data bound object has a property that has no Resources collection, but has only a ResourceId property.


    I have done that but I am not getting the desired results....resources assigned to appointments.

    Perhaps I am not binding the resources properly to the RadScheduler object? 
    My code is doing the manual method as documented on your website:

    resource =

     

    New Resource

     

     

    resource.Id =

     

    New EventId(reader.GetString(1))

     

    resource.Name = reader.GetString(0)

    resource.Color =

     

     

    Color.Beige

     

    resource.Visible =

     

     

    True

     

     

    RadScheduler1.Resources.Add(resource)


    Is there a correct way of binding resources to the scheduler so the appointment can associate them?

  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 29 Sep 2010 Link to this post

    Hi Mike,

    Thank you for writing back.
     
    If you want to map a resources collection to the RadScheduler control, you should to use a ResourcesMappingInfo object. We have such an example in the Examples application that comes with the installation package ( Scheduler >> DataBinding section). Or you can follow the code snippet below:
    private void BindToBusinessObjects()
    {
        this.appointments = new List<MyAppointment>();
     
        DateTime baseDate = new DateTime(2009, 3, 7);
        DateTime[] start = new DateTime[] { baseDate.AddHours(14.0), baseDate.AddDays(1.0).AddHours(9.0), baseDate.AddDays(2.0).AddHours(13.0) };
        DateTime[] end = new DateTime[] { baseDate.AddHours(16.0), baseDate.AddDays(1.0).AddHours(15.0), baseDate.AddDays(2.0).AddHours(17.0) };
        string[] summaries = new string[] { "Mr. Brown", "Mr. White", "Mrs. Green" };
        string[] descriptions = new string[] { "", "", "" };
        string[] locations = new string[] { "City", "Out of town", "Service Center" };
     
     
        MyAppointment appointment = null;
        for (int i = 0; i < summaries.Length; i++)
        {
            appointment = new MyAppointment(start[i], end[i], summaries[i],
                descriptions[i], locations[i]);
            this.appointments.Add(appointment);
        }
     
        MyAppointment recurringAppointment = new MyAppointment(baseDate.AddHours(7.0), baseDate.AddHours(10.0),
            "Recurring appointment with exceptions", null, null);
        recurringAppointment.RecurrenceRule = "FREQ=DAILY";
        MyAppointment notVisibleException = new MyAppointment(recurringAppointment.Start.AddDays(1.0), recurringAppointment.End.AddDays(1.0),
            "Recurring appointment with exceptions", null, null);
        notVisibleException.MasterAppointment = recurringAppointment;
        notVisibleException.Visible = false;
        recurringAppointment.Exceptions.Add(notVisibleException);
        this.appointments.Add(recurringAppointment);
     
        //int[] resourceIds = new int[] { 1, 2, 3 };
        string[] resourceNames = new string[] { "Dell Laptop", "Lenovo Laptop", "Toshiba Laptop" };
        this.resources = new List<MyResource>();
        for (int i = 0; i < resourceNames.Length; i++)
        {
            this.resources.Add(new MyResource(resourceNames[i]));
        }
     
        SchedulerBindingDataSource dataSource = new SchedulerBindingDataSource();
        dataSource.EventProvider.AppointmentFactory = this.radSchedulerDemo.AppointmentFactory;
     
        AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
        appointmentMappingInfo.Mappings.Add(new SchedulerMapping("Email", "Email"));
     
        appointmentMappingInfo.Start = "Start";
        appointmentMappingInfo.End = "End";
        appointmentMappingInfo.Summary = "Subject";
        appointmentMappingInfo.Description = "Description";
        appointmentMappingInfo.Location = "Location";
        appointmentMappingInfo.UniqueId = "Id";
        appointmentMappingInfo.Resources = "Resources";
        appointmentMappingInfo.ResourceId = "Id";
        appointmentMappingInfo.RecurrenceRule = "RecurrenceRule";
        appointmentMappingInfo.Exceptions = "Exceptions";
        appointmentMappingInfo.MasterEventId = "MasterAppointment";
        appointmentMappingInfo.Visible = "Visible";
        dataSource.EventProvider.Mapping = appointmentMappingInfo;
        dataSource.EventProvider.DataSource = this.appointments;
     
        ResourceMappingInfo resourceMappingInfo = new ResourceMappingInfo();
        resourceMappingInfo.Id = "Id";
        resourceMappingInfo.Name = "Name";
     
        dataSource.ResourceProvider.Mapping = resourceMappingInfo;
        dataSource.ResourceProvider.DataSource = this.resources;
     
        this.radSchedulerDemo.DataSource = dataSource;
    }

    We will update our documentation accordingly. If you have other questions, feel free to write back.

    Greetings,
    Dobry Zranchev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Mike
    Mike avatar
    7 posts
    Member since:
    Aug 2010

    Posted 29 Sep 2010 Link to this post

    thank you for the answer.

    I did find the code in the example application.  The documentation is lacking this information.  Thanks again!

    Mike
Back to Top
UI for WinForms is Visual Studio 2017 Ready