This is a migrated thread and some comments may be shown as answers.

Custom date aggregate

7 Answers 116 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Alex Dybenko
Top achievements
Rank 2
Alex Dybenko asked on 19 Jul 2016, 11:55 AM

Hi,

if datasource contains date/time field, it is expanded into Year, Quater, Month, etc. Is it possible to add custom aggregate e.g. Quater of hour (15 mins interval)?

Thanks

Alex

 

7 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 20 Jul 2016, 02:02 PM
Hello Alex,

Thank you for writing.

If I understand correctly, you would like to create a custom description grouping DateTime fields in hourly quarters. 

The required functionality can be accomplished by inheriting the PropertyGroupDescriptionBase class and defining a special group responsible for calculating the quarter hours. I am sending you attached a sample implementation which I believe should get you going. I am also attaching a screenshot showing the result on my end.

I hope this helps. Please let me know if you need further questions.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Alex Dybenko
Top achievements
Rank 2
answered on 09 Aug 2016, 08:48 AM

Hi Hristo,

I want to add weekday (mon, tue, wed ...) as custom description grouping as well, I can use the same approach like you posted, as I understand. But, can I add this new custom description grouping to date field aggregates list (Year, Month, Quater, etc)? Or maybe replace Seconds (which I don't need) with WeedDay?

I can also add it as calculted field in source query, but then I have it sorted alfabetically, rather than day order.So maybe it is possible to set at DataSourceProvider level how field can be sorted? What is best approach?

Thanks

Alex

0
Hristo
Telerik team
answered on 09 Aug 2016, 03:56 PM
Hi Alex,

Thank you for writing back.

The current implementation does not allow modifications to the groups used by the DateTimeGroupDescription class. In order to achieve your task, you would need to go with a similar approach to the one already discussed in this thread. 

Regarding your other question, you would need to create a custom group . It is used together with a particular description and can be assigned in its initialization, for example. The following thread discusses a similar matter: http://www.telerik.com/forums/pivotgrid-custom-column-sorting-(ordering).

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Alex Dybenko
Top achievements
Rank 2
answered on 12 Aug 2016, 06:59 AM

Hi Hristo,

thanks, have solved it with custom group comparer.

Alex

0
Alex Dybenko
Top achievements
Rank 2
answered on 16 Aug 2016, 08:16 AM

Hi Hristo,

2 more related questions:

- say I want to show products names on PivotGrid, but sorted by product ID (or some product code), rather than ProductName. I can make a new custom group comparer, like for weekday, where I can query my database and load hashtable with product names and IDs. But, if Product ID is already in PivotGrid datasource - is there a better approach?

- having custom group comparer - how to add a new sort field to SortOptionsDialog and get selected fields/order from it? Perhaps you have a sample?

Thanks

Alex

0
Hristo
Telerik team
answered on 18 Aug 2016, 03:26 PM
Hi Alex,

Thank you for writing.

The group comparer allows you to define a custom sort order and it should not be a problem to sort certain fields according to the value of others. In your scenario, basically, you would need to store the unique names and map them to the respective Ids. It will not be necessary to execute a new query. I can suggest performing this operation when you have the data locally or while you are receiving it.

The easiest solution to achieve the required functionality as per your second question is to add a new RadMenuItem in the filter popup. Then on click, you can directly add the custom comparer or if needed show a dialog of your own providing the necessary information.

I am sending you attached a sample project demonstrating the suggested approach. Additionally, you may also want to use a custom comparer with the tree holding the distinct values. I included an example it too.

I hope this information is useful. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Alex Dybenko
Top achievements
Rank 2
answered on 23 Aug 2016, 06:19 AM

Thanks Hristo,

your solution works fine for me!

Alex

Tags
PivotGrid and PivotFieldList
Asked by
Alex Dybenko
Top achievements
Rank 2
Answers by
Hristo
Telerik team
Alex Dybenko
Top achievements
Rank 2
Share this question
or