QueryableDateTimeGroupDescription
In this article you will learn how to use a QueryableDateTimeGroupDescription with your DateTime and DateTimeOffset data.
QueryableDateTimeGroupDescription
QueryableDateTimeGroupDescription is used when you want to group your data by a property of type DateTime or DateTimeOffset. It has the following properties:
PropertyName : defines the name of the property by which the data will be grouped. It is mandatory to set a value.
Step : defines the grouping interval. Default value is Year, but you can change it to one of the following: Quarter, Month, Day, Week Hour, Minute, Second (The Week, Hour, Minute and Second steps are available since the 2019.2.729 version).
If you have the following dates: 01-01-2013 and 20-02-2013 and you set Step to Year, the two values will be in one group - 2013. But if you change the step to Month, the values will be in two different groups - January and February.
When you have a property of type DateTime (DateTimeOffset), you can create several QueryableDateTimeGroupDescription with different steps. You may also create a QueryablePropertyGroupDescription - this way the DateTime will be treated as a string and grouped as such. All of them can be used simultaneously. You can add the description in RowGroupDescriptions or ColumnGroupDescriptions collections of QueryableDataSourceProvider.
Example 1: Adding multiple group descriptions in xaml
Example 2: Adding multiple group descriptions in code
Modify FieldTree of RadPivotFieldList
By default RadPivotFieldList will show the following steps in its FieldTree for each QueryableDateTimeGroupDescription: Year, Month, Quarter, Day (you will also see one additional item, which will create a QueryablePropertyGroupDescription instead of a QueryableDateTimeGroupDescription).
That said, you can set four more steps in code or xaml - Week, Hour, Minute, Second(Those 4 steps were added with the 2019.2.729 version). In order to add them to the FieldTree of RadPivotFieldList you have two options:
-
Handle the GetDescriptionsDataAsyncCompleted of the FieldDescriptionsProvider.
Examples 3 and 4 below demonstrate how the GetDescriptionsDataAsyncCompleted event can be handled in xaml and code respectively. Example 5 demonstrate a sample implementation of the event handler that shows the Week, Hour, Minute and Second steps for a property named "Date".
Example 3: Handling the GetDescriptionsDataAsyncCompleted event in xaml
Example 4: Handling the GetDescriptionsDataAsyncCompleted event in code
Example 5: Showing the additional steps
-
Create a custom QueryableFieldDescriptionsProvider.
Example 6 demonstrates how to create a custom QueryableFieldDescriptionsProvider and ovveride its GetFieldDescriptionHierarchy method in order to show the additional steps. Examples 7 and 8 demonstrate how to use the created class by setting it to the FieldDescriptionsProvider property of the QueryableDataProvider.
Example 6: Custom QueryableFieldDescriptionsProvider
Example 7: Using the CustomQueryableFieldDescriptionsProvider in xaml
Example 8: Using the CustomQueryableFieldDescriptionsProvider in code