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

[Solved] Resource Grouping

3 Answers 220 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
shawn
Top achievements
Rank 1
shawn asked on 08 Apr 2008, 07:56 PM

I am attempting to use the ResourceView of the RadScheduler to show me the Appointments for specific resources. I have specified that the ForeignKey for the ResourceMapping is the ResourceID field which is a CustomAttribute of the Appointment object. I have verified that the data for the ResourceID field is being correctly populated in the Appointment and I have also verified that the resources are being bound to the control. My question is this: when I try to use the ResourceView, I can see the resources, but none of the Appoinments that use those Resources. Am I missing something for the relationship between these two to make this work? Below is the code(s) I am using to establish the relationship:

<ResourceTypes> 
  <telerik:ResourceType   
    ForeignKeyField="ResourceID"   
    DataSourceID="odsResources"       
    Name="Route" 
    KeyField="Id"    
    TextField="RouteName" /> 
 </ResourceTypes> 

The code that populates the Appoinment object is below:

appts = new List<TelerikAppointment>();  
 
foreach (Schedule s in schedules)  
{                         
  temp = new Appointment();  
  temp.Attributes["ResourceID"] = s.Route.Id.ToString();  
  temp.Attributes["MobilityID"] = s.Appointment.Mobility.Id.ToString();  
  temp.Attributes["FromID"]     = s.Appointment.FromAddress.Id.ToString();  
  temp.Attributes["ToID"]       = s.Appointment.ToAddress.Id.ToString();  
  temp.End                      = s.EndTime;  
  temp.ID                       = s.Id;  
  temp.Start                    = s.StartTime;  
  temp.Subject                  = s.Description;  
 
  appts.Add(temp);  
}  
 
this.RadScheduler1.DataSource = appts; 

The RadScheduler control has defined the custom attributes and the group by in the control declaration. Below is the abbreviated control declaration:

CustomAttributeNames="ResourceID,MobilityID,FromID,ToID" 
DataEndField="End"   
DataKeyField="ID"   
DataStartField="Start"   
DataSubjectField="Subject" 
DayEndTime="22:00:00" 
DayStartTime="05:00:00" 
EnableCustomAttributeEditing="true" 
FirstDayOfWeek="Sunday" 
GroupBy="Route" 

Again, when I switch to the ResourceView, I can see the resources, there simply aren't any appointments assigned to the resources.

Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
shawn
Top achievements
Rank 1
answered on 11 Apr 2008, 07:18 PM
I'm guessing no one else has had this issue?
0
Peter
Telerik team
answered on 14 Apr 2008, 10:24 AM
Hello Shawn,

If you databind RadScheduler to a dynamically created List of appointments, you need to add the resources dynamically as well. For this type of scenario, it is best ot follow the Binding To Generic List online example. Please, review it and let us know if you have further questions.

All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
shawn
Top achievements
Rank 1
answered on 16 Apr 2008, 07:08 PM
Thank you, Peter. After further investigation into the *Bind to Generic List* I discovered the solution and it is now working. The solution is below for those who may encounter a similar issue.

I have a List<Schedule> of appoinments bound to the control and a List<Route> of resources bound to the control. My Schedule object has a property of type Route, and the ID of the route serves as foreign key to the resource. The resources are populated from the List<Route> with the key being the ID and the text being the Route name.

resType                 = new ResourceType("Route");  
resType.ForeignKeyField = "Route.Id";  
this.RadScheduler1.ResourceTypes.Clear();  
this.RadScheduler1.ResourceTypes.Add(resType); 
foreach (Route r in routes)  
{  
    this.RadScheduler1.Resources.Add(new Resource("Route", r.Id, r.RouteName));  

This code is in a method that is invoked just before binding the Schedules to the Scheduler.

Cheers...
Tags
Scheduler
Asked by
shawn
Top achievements
Rank 1
Answers by
shawn
Top achievements
Rank 1
Peter
Telerik team
Share this question
or