11 Answers, 1 is accepted
RadPivotGrid can be grouped by dates - the properties of type DateTime will automatically shown in RadPivotFieldList, so you can easily group by them using drag and drop. For more details on how to use the DateTimeGroupDescription, please check the following article from our online help documentation:
https://docs.telerik.com/devtools/wpf/controls/radpivotgrid/features/localdatasourceprovider/datetimegroupdescription
As for min and max - could you please share more details on the exact scenario you need to achieve? In RadPivotFieldList you could filter the dates as desired using Label Filter.
You could also check the PivotGrid demos in our WPF samples application - please let me know if you have any other questions.
Regards,
Kalin
Progress Telerik
Example in the Pivot grid with PivotFieldList demo.
I remove Sum Of Quantities from aggregates. Drag Date into aggregates and then show Max(Dates) into the grid (instead of sum quantities).
Thanks for the further details. With the current implementation there aren't built-in DateTime aggregate functions. However you should be able to achieve the same by implementing a custom aggregate function as demonstrated in the Custom Aggregate Description example from our demos (this Silverlight link, however the demo is identical for WPF):
https://demos.telerik.com/silverlight/#PivotGrid/CustomAggregateDescription
I'm preparing WPF demo demonstrating the approach - will get back to you when I'm done.
Regards,
Kalin
Progress Telerik
I'm attaching sample project demonstrating how to implement a custom MaxDate aggregate function.
Hope this helps.
Regards,
Kalin
Progress Telerik
Ok, it works, thank you.
I have already edit it to manage also datetime? and added functions Min and Average.
There is only a not correct behaviour
In the demo, in MainWindow.xaml remove this code
<!--<
pivot:LocalDataSourceProvider.AggregateDescriptions
>
<
local:MaxDateAggregateDescription
PropertyName
=
"Date"
>
<
local:MaxDateAggregateDescription.AggregateFunction
>
<
local:MaxDateAggregateFunction
/>
</
local:MaxDateAggregateDescription.AggregateFunction
>
</
local:MaxDateAggregateDescription
>
</
pivot:LocalDataSourceProvider.AggregateDescriptions
>-->
Now the application start with no aggregates. If I add Date to aggregates by default it use Sum aggregation and pivot values is Error.
Than I can change to count or max ecc... and it works
How can I fix it?
The reason for this behavior is that the MaxDateAggregateDescription uses Sum function by default, so for this scenario we would have change the AggregateFunction property as well (as it is done in MainWindow.xaml). This can be done for example in the constructor of the MaxDateAggreagateDescription class:
public
MaxDateAggregateDescription()
{
this
.AggregateFunction =
new
MaxDateAggregateFunction();
}
Please give it a try and let me know if you have any other questions.
Regards,
Kalin
Progress Telerik
Ok, it works.
Thank you.
Hi,
How can I set the date cells alignment to center?
You should be able to change the alignment by applying a custom header or cell template - prepare a DataTemplate with TextBlock aligned as desired and apply it to the needed headers or cell. Please refer to the following article:
https://docs.telerik.com/devtools/wpf/controls/radpivotgrid/styles-and-templates/templating-cells
Let me know if you have any further questions or concerns.
Regards,
Kalin
Progress Telerik
Hi,
in the example it use description.PropertyName to check the property info.
I would like to create a more generic function. Is it possible to check the DataType property of PivotFieldInfo?
The PropertyAggregateDescriptionBase class has protected DataType property, so for the custom MaxDateAggregateDescription discussed in the previous posts this property can be easily exposed and checked afterwards in the CellTemplateSelector. Or you could simply check the custom aggregate description.
Let me know if this helps. Do you want to change the appearance of the header cells as well?
Regards,
Kalin
Progress Telerik