This is a migrated thread and some comments may be shown as answers.

Assigning Resources to Appointments

4 Answers 144 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 20 Sep 2010, 05:15 PM
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


 

 

4 Answers, 1 is accepted

Sort by
0
Dobry Zranchev
Telerik team
answered on 23 Sep 2010, 12:06 PM
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
0
Mike
Top achievements
Rank 1
answered on 23 Sep 2010, 09:39 PM
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?

0
Dobry Zranchev
Telerik team
answered on 29 Sep 2010, 07:56 AM
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
0
Mike
Top achievements
Rank 1
answered on 29 Sep 2010, 04:47 PM
thank you for the answer.

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

Mike
Tags
Scheduler and Reminder
Asked by
Mike
Top achievements
Rank 1
Answers by
Dobry Zranchev
Telerik team
Mike
Top achievements
Rank 1
Share this question
or