Custom date aggregate

8 posts, 1 answers
  1. Alex Dybenko
    Alex Dybenko avatar
    119 posts
    Member since:
    Jan 2005

    Posted 19 Jul Link to this post

    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

     

  2. Answer
    Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 20 Jul Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Alex Dybenko
    Alex Dybenko avatar
    119 posts
    Member since:
    Jan 2005

    Posted 09 Aug in reply to Hristo Link to this post

    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

  5. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 09 Aug Link to this post

    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 comparer. 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.
  6. Alex Dybenko
    Alex Dybenko avatar
    119 posts
    Member since:
    Jan 2005

    Posted 12 Aug in reply to Hristo Link to this post

    Hi Hristo,

    thanks, have solved it with custom group comparer.

    Alex

  7. Alex Dybenko
    Alex Dybenko avatar
    119 posts
    Member since:
    Jan 2005

    Posted 16 Aug in reply to Alex Dybenko Link to this post

    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

  8. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 18 Aug Link to this post

    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 for 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.
  9. Alex Dybenko
    Alex Dybenko avatar
    119 posts
    Member since:
    Jan 2005

    Posted 23 Aug in reply to Hristo Link to this post

    Thanks Hristo,

    your solution works fine for me!

    Alex

Back to Top
UI for WinForms is Visual Studio 2017 Ready