Telerik blogs
Q3 marks the release of some fantastic new features in the RadControls for WinForms. I know many of you have been waiting for one feature in particular... resource grouping. Well, I'm happy to say, the wait is over, resource grouping is here! Today, I am going to take some time out to explain to you how it works.
 
Resource Grouping

Adding Resources Programmatically

Creating and adding resources to the RadScheduler is quite simple. In fact, assigning resources to appointments is by no means a new feature of the RadScheduler. The following code creates and adds a resource to the RadScheduler:

Resource resource = new Resource();
resource.Id = new EventId(0);
resource.Name = "Robert Shoemate";
resource.Color = Color.Blue;
resource.Image = Image.FromFile("robert.jpg");
resource.Visible = true;
radScheduler1.Resources.Add(resource);

 
If you've used resources in the past, you will notice that there is a new property, Color. The color property is used to set the color of the grouping section in the RadScheduler. If you refer to the image of the RadScheduler above, you will notice that each section is a unique color based on its respective resource.

Adding Resources With DataBinding

If you prefer to bind data to the RadScheduler rather than creating it by hand, you are in luck. The SchedulerBindingDataSource object included with the RadControls for WinForms handles this for you. I will spare you the details of using the SchedulerBindingDataSource, as you can read about it here.

Resource Mapping

Resource Grouping

Enabling the RadScheduler to use resource grouping is quite simple. Setting the GroupType property of the RadScheduler to GroupType.Resource will do the trick. You can also set the visible resources per view using the ResourcesPerView property.

radScheduler1.GroupType = GroupType.Resource;
radScheduler1.ActiveView.ResourcesPerView = 3;

 

If the end user has the ability to change the active view, you will need to make sure to subscribe to the ActiveViewChanged event so you can set the ResourcesPerView property on the new view when it is generated.

private void radScheduler1_ActiveViewChanged(object sender, SchedulerViewChangedEventArgs e)
{
    radScheduler1.ActiveView.ResourcesPerView = 3;
}

 

Scrolling through the grouped resources is as easy as using the horizontal scroll bar available at the bottom of the scheduler control. When creating a new appointment, you can specify what resource that appointment belongs to and the appointment will show up under the respective resource grouping. You can also drag appointments between resource groupings. Upon doing so, the dragged appointment's resource will automatically be updated.


Comments

Comments are disabled in preview mode.