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

Help - Grouping - Aggregate Column Total

3 Answers 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 01 Sep 2009, 04:11 PM
I am sure I have coded something incorrectly but I am incapable of figuring it out:

The code I am about to post exhibits the following problems:
1) Column totals don't show up at all
2) Footer is not right justified ( in the grand total that does show up )

I have loaded and inspected the example Vlad posted here: SilverlightApplication2 and the application works just fine for me.  I have to be missing some key component but I just cannot discover it.

Here is the grid XAML:
<telerikGridView:RadGridView AutoGenerateColumns="False" x:Name="cGrid"  
                            ShowGroupPanel="False"  
                            CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed"  
                            ShowGroupFooters="True" ShowColumnFooters="True"
    <telerikGridView:RadGridView.Columns> 
        <telerikGridView:GridViewDataColumn HeaderText="Asset" UniqueName="AssetName" Width="200" /> 
        <telerikGridView:GridViewDataColumn HeaderText="Cusip" UniqueName="Cusip" Width="Auto"/> 
        <telerikGridView:GridViewDataColumn HeaderText="Shares" UniqueName="Shares" Width="Auto" TextAlignment="Right" /> 
        <telerikGridView:GridViewDataColumn HeaderText="MarketValue" UniqueName="MarketValue" Width="Auto" TextAlignment="Right" /> 
    </telerikGridView:RadGridView.Columns> 
    <telerikGridView:RadGridView.GroupDescriptors> 
        <telerikData:GroupDescriptor Member="ReportType" SortDirection="Ascending" /> 
    </telerikGridView:RadGridView.GroupDescriptors> 
</telerikGridView:RadGridView> 

And here is where I actually create the aggregate functions and assign their properties:
    foreach (var externalColumn in e.Result.ExternalDataColumns) 
    { 
        switch (externalColumn.ColumnName.ToLower()) 
        { 
            case "marketvalue": 
                { 
                    var col = cGrid.Columns["MarketValue"] as GridViewDataColumn; 
                    Debug.Assert( col != null, "Columns[MarketValue] is null."); 
                    if ( col != null ) 
                    { 
                        var sum = new SumFunction(); 
                        sum.ResultFormatString = externalColumn.FormatString; 
                        sum.SourceField = "MarketValue"
                         
                        col.DataFormatString = externalColumn.FormatString; 
                        col.FooterTextAlignment = TextAlignment.Right; 
                        col.AggregateFunctions.Add( sum ); 
                    } 
                } 
                break; 
            case "shares": 
                { 
                    var col = cGrid.Columns["Shares"] as GridViewDataColumn; 
                    Debug.Assert(col != null, "Columns[Shares] is null."); 
                    if (col != null) 
                    { 
                        var sum = new SumFunction(); 
                        sum.ResultFormatString = externalColumn.FormatString; 
                        sum.SourceField = "Shares"
 
                        col.DataFormatString = externalColumn.FormatString; 
                        col.FooterTextAlignment = TextAlignment.Right; 
                        col.AggregateFunctions.Add(sum); 
                    } 
                } 
                break; 
 
        } 
    } 

That is about it for the entire user control other than showing how I got the data back from the wcf server.

Here is what I get displayed: Grid Snapshot


3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 04 Sep 2009, 01:35 PM
Hello Jim,

I've made for you small example project to illustrate you how to achieve this - unfortunately you are right about the alignment issue and we will do our best to include fix for this in our next internal build (next week).

Please check the attachment and let me know how it goes.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 09 Nov 2009, 02:37 PM
Hi Vlad,

Do you know if the alignment issue is still active in the last version of the controls ? Because i'm still having the problem....


Thanks !
0
Kalin Milanov
Telerik team
answered on 12 Nov 2009, 12:39 PM
Hello Thomas LEBRUN,

Unfortunately this fix proved more complicated that we originaly thought. We are currently working on it and are hopeful we will have a solution soon.

I apologize for the inconvenience caused.

Greetings,
Kalin Milanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Jim
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Thomas LEBRUN
Top achievements
Rank 1
Kalin Milanov
Telerik team
Share this question
or