|
| 1 | +--- |
| 2 | +title: Hierarchical Grouping |
| 3 | +page_title: Hierarchical Grouping |
| 4 | +description: "Learn how to enable the hierarchical grouping of the Telerik UI for {{ site.framework }} Scheduler resources." |
| 5 | +slug: scheduler_resources_grouping_hierarchical |
| 6 | +position: 5 |
| 7 | +--- |
| 8 | + |
| 9 | +# Hierarchical Grouping |
| 10 | + |
| 11 | +The hierarchical resource grouping feature allows you to group the resources of the Scheduler horizontally or vertically and display the resources in a parent-child structure. |
| 12 | + |
| 13 | +When you enable the hierarchical grouping, the groups consist of parents and children, where each parent resource member can have a different child resource group. For example, if the Scheduler has **Rooms** as a parent resource, different **Attendees** can be assigned to each room. In this setup, the parent resources (such as rooms, attendees, equipment, and more) are displayed as rows or columns based on the defined orientation ([vertical]({% slug scheduler_resources_grouping_vertical %}) or [horizontal]({% slug scheduler_resources_grouping_horizontal %})), with child resources nested beneath them. |
| 14 | + |
| 15 | +To configure the hierarchical grouping of the Scheduler's resources: |
| 16 | + |
| 17 | +1. Add the desired resources in the [`Resources()`](/api/kendo.mvc.ui.fluent/schedulergroupbuilder#resourcessystemstring) configuration. The order of the resources must follow the parent-child relation. The last resource in the `Resources()` configuration must not be a parent. |
| 18 | +1. Use the [`DataParentValueField()`](/api/kendo.mvc.ui.fluent/schedulerresourcebuilder#dataparentvaluefieldsystemstring) option in the child resource to specify the name of the field that holds the parent value (the parent value equals the value of the field defined as `DataValueField` in the parent resource.) |
| 19 | + |
| 20 | + ```HtmlHelper |
| 21 | + @(Html.Kendo().Scheduler<MeetingViewModel>() |
| 22 | + .Name("scheduler") |
| 23 | + .Resources(resource => |
| 24 | + { |
| 25 | + resource.Add(m => m.RoomID) // Parent resource. |
| 26 | + .Title("Room") |
| 27 | + .Name("Rooms") |
| 28 | + .DataTextField("Text") |
| 29 | + .DataValueField("Value") |
| 30 | + .DataColorField("Color") |
| 31 | + .BindTo(new[] { |
| 32 | + new { Text = "Meeting Room 101", Value = 1, Color = "#6eb3fa" }, |
| 33 | + new { Text = "Meeting Room 201", Value = 2, Color = "#f58a8a" } |
| 34 | + }); |
| 35 | +
|
| 36 | + resource.Add(m => m.Attendees) // Child resource. |
| 37 | + .Title("Attendees") |
| 38 | + .Name("Attendees") |
| 39 | + .Multiple(true) |
| 40 | + .DataTextField("Text") |
| 41 | + .DataValueField("Value") |
| 42 | + .DataColorField("Color") |
| 43 | + .DataParentValueField("Parent") // The "Parent" field in the "SchedulerResourceModel" Model holds the value of the "Value" field in the "Room" resource. |
| 44 | + .BindTo(new List<SchedulerResourceModel>() { |
| 45 | + new SchedulerResourceModel(){ Text = "Alex", Color="red", Value = 1}, |
| 46 | + new SchedulerResourceModel(){ Text = "Bob", Color="green", Value = 2, Parent = 1 } , |
| 47 | + new SchedulerResourceModel(){ Text = "Charlie",Color="yellow", Value = 3, Parent = 2 } |
| 48 | + }); |
| 49 | + }) |
| 50 | + ...// Additional configuration. |
| 51 | + ) |
| 52 | + ``` |
| 53 | + {% if site.core %} |
| 54 | + ```TagHelper |
| 55 | + @addTagHelper *, Kendo.Mvc |
| 56 | +
|
| 57 | + @{ |
| 58 | + var roomsData = new[] |
| 59 | + { |
| 60 | + new { Text = "Meeting Room 101", Value = 1, Color = "#6eb3fa" }, |
| 61 | + new { Text = "Meeting Room 201", Value = 2, Color = "#f58a8a" } |
| 62 | + }; |
| 63 | +
|
| 64 | + var attendeesData = new List<SchedulerResourceModel>() { |
| 65 | + new SchedulerResourceModel(){ Text = "Alex", Color="red", Value = 1}, |
| 66 | + new SchedulerResourceModel(){ Text = "Bob", Color="green", Value = 2, Parent = 1 } , |
| 67 | + new SchedulerResourceModel(){ Text = "Charlie",Color="yellow", Value = 3, Parent = 2 } |
| 68 | + }; |
| 69 | + } |
| 70 | + <kendo-scheduler name="scheduler"> |
| 71 | + <resources> |
| 72 | + <resource field="RoomID" title="Room" name="Rooms" datatextfield="Text" datavaluefield="Value" datacolorfield="Color" bind-to="@roomsData"> // Parent resource. |
| 73 | + </resource> |
| 74 | + <resource // Child resource. |
| 75 | + field="Attendees" |
| 76 | + title="Attendees" |
| 77 | + name="Attendees" |
| 78 | + multiple="true" |
| 79 | + datatextfield="Text" |
| 80 | + datavaluefield="Value" |
| 81 | + datacolorfield="Color" |
| 82 | + dataparentvaluefield="Parent" // The "Parent" field in the "SchedulerResourceModel" Model holds the value of the "Value" field in the "Room" resource. |
| 83 | + bind-to="@attendeesData"> |
| 84 | + </resource> |
| 85 | + </resources> |
| 86 | + <!--Additional configuration--> |
| 87 | + </kendo-scheduler> |
| 88 | + ``` |
| 89 | + {% endif %} |
| 90 | +
|
| 91 | + > Only the last one of the resources can be configured to allow [multiple instance resources]({% slug htmlhelpers_scheduler_resources_aspnetcore %}#multiple-resource-types). |
| 92 | +
|
| 93 | +1. Add the [`Group()`](/api/kendo.mvc.ui.fluent/schedulerbuilder#groupsystemaction) configuration and specify the names of the resources in the `Resources()` option. |
| 94 | +1. To group the resources vertically, set the [`Orientation()`](/api/kendo.mvc.ui.fluent/schedulergroupbuilder#orientationkendomvcuischedulergrouporientation) option to `SchedulerGroupOrientation.Vertical`. The available options of the `SchedulerGroupOrientation` setting are `Default` (horizontal), `Horizontal`, and `Vertical`. |
| 95 | +
|
| 96 | + ```HtmlHelper |
| 97 | + @(Html.Kendo().Scheduler<MeetingViewModel>() |
| 98 | + .Name("scheduler") |
| 99 | + .Group(group => group.Resources("Rooms", "Attendees").Orientation(SchedulerGroupOrientation.Vertical)) |
| 100 | + ...// Additional configuration. |
| 101 | + ) |
| 102 | + ``` |
| 103 | + {% if site.core %} |
| 104 | + ```TagHelper |
| 105 | + @addTagHelper *, Kendo.Mvc |
| 106 | +
|
| 107 | + <kendo-scheduler name="scheduler"> |
| 108 | + <group orientation="vertical"> |
| 109 | + <resources> |
| 110 | + <group-resource name="Rooms" /> |
| 111 | + <group-resource name="Attendees" /> |
| 112 | + </resources> |
| 113 | + </group> |
| 114 | + <!--Additional configuration--> |
| 115 | + </kendo-scheduler> |
| 116 | + ``` |
| 117 | + {% endif %} |
| 118 | +
|
| 119 | +## Next Steps |
| 120 | +
|
| 121 | +* [Implementing Date Grouping of the Scheduler Resources]({% slug scheduler_resources_grouping_date %}) |
| 122 | +
|
| 123 | +## See Also |
| 124 | +
|
| 125 | +* [Hierarchical Grouping by the Scheduler for {{ site.framework }} (Demo)](https://demos.telerik.com/{{ site.platform }}/scheduler/resources-grouping-hierarchical) |
| 126 | +* [Server-Side API of the Scheduler HtmlHelper](/api/scheduler) |
| 127 | +{% if site.core %} |
| 128 | +* [Server-Side API of the Scheduler TagHelper](/api/taghelpers/scheduler) |
| 129 | +{% endif %} |
| 130 | +* [Client-Side API of the Scheduler](https://docs.telerik.com/kendo-ui/api/javascript/ui/scheduler) |
0 commit comments