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

Group Aggregates

9 Answers 52 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard Harrigan
Top achievements
Rank 1
Richard Harrigan asked on 19 Feb 2014, 11:45 PM
Hi,

The html grid can do Group Aggregates but can they be done in the xaml version?  If not is Aggregation a committed future feature and if so when will it be available?   Maybe a better way to ask the question; is Telerik committed to keeping the Xaml version as feature rich as the Html version.   Can you provide a current detailed features doc for both formats showing the differences.  I am trying to make decisions on developer resources and really don't have any html expertise to speak of.  Does it make any sense to develop an app in xaml but include an html version of the grid?  If it's possible then how would you architect it.

Thanks
Rich

9 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 24 Feb 2014, 04:19 PM
Hello Richard,

Thank you for contacting us.

I have attached a table with comparison of the features supported by the XAML and the HTML versions of the RadDataGrid control. If you need more detailed information about any of the listed features, please, do not hesitate to ask.

As to the group aggregates, the XAML version also supports such feature, although there is no UI for displaying the aggregated values. Here is more information from our online documentation about the aggregates API of the XAML version of the grid:

At this moment it is not possible to use HTML version of the controls in a XAML project and vice versa.

I hope this was useful. Please, let us know if you have further questions.

Regards,
Rositsa Topchiyska
Telerik
0
Richard Harrigan
Top achievements
Rank 1
answered on 26 Feb 2014, 03:43 PM
Hi Rositsa

Thanks for your response.  I was hoping you could provide an example program displaying Aggregate value(s) in the UI at each group break.  Could you also do this without using xaml as I need to do this dynamically.  This is above my skill level and an example would be most helpful.

Thanks
Rich
0
Rosy Topchiyska
Telerik team
answered on 28 Feb 2014, 08:36 AM

Hello Richard,

I have attached a sample project that demonstrates how you can customize the group headers to show aggregated group values. You have to group by the Name column to see the result. The grid is created in code behind and I have defined the DataTemplate for the group headers in the resources of the page. The context of the group headers is of type GroupHeaderContext that contains information about the grid and the corresponding group. You can see in the AggregateValueConverter class how you can get an aggregated value using that context. You can also take a look at this article from our online documentation:

You can further customize the group headers to show the aggregated value only when the group is expanded by using GroupHeaderTemplateSelector instead of GroupHeaderTemplate.

I hope this will give you an idea of how to use the grid aggregates. Feel free to contact us should you have any other questions.

Regards,
Rositsa Topchiyska
Telerik
0
Richard Harrigan
Top achievements
Rank 1
answered on 02 Mar 2014, 12:48 AM
Hi Rositsa,

I tried your sample and it worked great.  It helped me understand how the Telerik xaml grid for store apps works for Aggregates. I made a few changes for my purposes.  I removed the Data class and in the ViewModel created an ExpandoObject to replace  it.  That worked perfectly.  Since I will be creating grids dynamically based on an end-user adhoc sql query I will also need to create the <DataTemplate x:key="ColumnHeader"> in code-behind.  If possible will you please provide a code snippet to do that which I can use to replace the xaml. 

I also need to pass a parameter to the ValueConverter that contains the AggregateIndex. I added a ConverterParameter to the xaml so that I could use one valueconverter for each aggregate type (i.e. Sum. Avg, StdDev, etc.).  Meaning, if more that one column uses the same function only one value converter will be needed. 

<Run Text="{Binding Converter={StaticResource ConverterAvg}, ConverterParameter='0'}"/>

To run your sample required me to install visual studio 2013 (I installed the Express version).  For some reason when I look at a class in the quickwatch dialog I only get one line showing.  It does not show me the properties of the class.  Is there something I need to set that allows me to see the detail?

Thank you for the superior support work
Rich
0
Rosy Topchiyska
Telerik team
answered on 05 Mar 2014, 08:19 AM
Hi Richard,

Thank you for the questions.

If you want to create a DataTemplate object in code, you can use the XamlReader.Load(...) method that uses a well formatted XAML code to create the corresponding object. If you use this approach, you will have to define the value converter in the Application.Resources in the App.xaml file instead of adding it to the Page.Resources. I have modified the sample project from my last reply to create the DataTemplate in code behind.

I couldn't understand whether you have some problem with the value converter. If you do, could you please elaborate a bit more on the scenario. 

I have tested the sample project with Visual Studio Express 2013 and I was able to see the RadDataGrid properties in the quick watch (I have attached a screenshot). I found this article that describes a similar issue: 
http://weblog.west-wind.com/posts/2013/Nov/21/Visual-Studio-2013-Could-not-evaluate-Expression-Debugger-Abnormality
You can take a look and see if this is relevant to your problem.

I hope this was useful. Please, let us know if you have other questions.

Regards,
Rositsa Topchiyska
Telerik
0
Richard Harrigan
Top achievements
Rank 1
answered on 05 Mar 2014, 06:31 PM
Hi Rositsa,

The change you made to the sample is just what I needed.   I do have another question however;  how do I determine when a grouping is added or removed?  I didn't see any event for it.

Thanks
Rich

I got a email from Kiril about using support tickets.  I asked for clarification.

0
Rosy Topchiyska
Telerik team
answered on 06 Mar 2014, 03:46 PM
Hi Richard,

The RadDataGrid exposes a GroupDescriptors property(collection) that contains all descriptors that are currently applied to the grid. If you wish to know when a grouping is added or removed, you can subscribe to the GroupDescriptors.CollectionChanged event.

I hope this helps.

Regards,
Rositsa Topchiyska
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

0
Richard Harrigan
Top achievements
Rank 1
answered on 07 Mar 2014, 04:11 PM
Hi Rositsa,

Hopefully, one last question on this subject.  I would like to display the aggregates in the associated column and show them at the beginning and/or end of each group.  Please see my example below.
   
****** Example ******

Product                        Price               Quantity                 Amount
Apples                                              Sum:    140           Sum: 210.00
                                                         Avg:  46.66            Avg:   70.00
Apples                           1.50                          20                      30.00
Apples                           1.50                          40                      60.00
Apples                           1.50                          80                    120.00
_____________________________________________________      
                                                        Sum:    140           Sum: 210.00
                                                        Avg:  46.66            Avg:   70.00

Thanks
Rich

  

    

                       
 
0
Rosy Topchiyska
Telerik team
answered on 12 Mar 2014, 09:51 AM
Hello Richard,

Thank you for the question.

The RadDataGrid does not provide such functionality, but this can be achieved if you fix the width of the grid columns. Then in the DataTemplate of the group header, you can calculate the position where you wish to display the aggregated values. This will work fine if the user is not allowed to reorder the columns. I have attached an example.

Please, let us know if this works for you.

Regards,
Rositsa Topchiyska
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
Tags
Grid for XAML
Asked by
Richard Harrigan
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Richard Harrigan
Top achievements
Rank 1
Share this question
or