In This Topic
Grouping is the process of distributing appointments to different groups based on the value of one or more of their properties. Each view mode of the schedule has a different collection of groupings referenced by its Groupings property. This allows you to group appointments differently depending on the currently active view mode. Note that the order of the grouping is important, too.
Nevron Schedule provides support for 2 types of groupings:
Date Range Groupings
Date range groupings group appointments based on their start and end time. The currently supported date range groupings are:
- Day groupings - group appointments by day, for example May 01, May 02, etc. Day groupings are implemented by the NDayGrouping class and are by default added to the day view mode and the week view mode of the schedule.
- Week groupings - group appointments by week, for example May 01 - May 07, May 08 - May 15, etc. Week groupings are implemented by the NWeekGrouping class and are by default added to the month view mode of the schedule.
The only schedule view mode, which does not have a date range grouping added by default is the timeline view mode.
Schedule Group Groupings
Schedule group groupings are implemented by the NGroupGrouping class and group appointments based on the schedule group and item they are associated with.
The following code example shows how to create and add a schedule group named "Activity" with items "Work", "Rest" and "Travel":
Creating schedule group using string literals |
Copy Code
|
schedule.Groups.Add(new NScheduleGroup("Activity", new string[] { "Work", "Rest", "Travel" }));
|
It is considered good practice to define groups using constants instead of string literals. Thus you will be able to easily assign groups and items to appointments later without the risk of typos. Here's an example:
Creating schedule group using constants |
Copy Code
|
public const string ActivityGroup = "Activity";
public const string Work = "Work";
public const string Rest = "Rest";
public const string Travel = "Travel";
...
public void CreateGroups()
{
// Add a schedule group
schedule.Groups.Add(new NScheduleGroup(ActivityGroup, new string[] { Work, Rest, Travel }));
}
|
Finally, you should create schedule group groupings, which utilize the created schedule group and add them to the schedule view modes you want. The following example creates and adds a grouping to the day view mode and the week view mode of a schedule.
Create and add groupings |
Copy Code
|
schedule.DayViewMode.Groupings.Add(new NGroupGrouping(ActivityGroup));
schedule.WeekViewMode.Groupings.Add(new NGroupGrouping(ActivityGroup));
|
See Also