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

How to get the aggregate colum value

5 Answers 164 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shirley
Top achievements
Rank 1
Shirley asked on 29 Dec 2011, 04:40 AM
HI,
I am using RadControls for Silverlight Q1 2011 SP1.I have a problem to get the value of aggregate colum. I want to print the dategrid, but don't know how tho get the value of aggregate colum , i don't want to calculate again manually.
Any Help?
Thanks!
my code is like this:

 

<CODE style="COLOR: #000">
<P><Rad:CEnjoyRadDataGrid  
AutoGenerateColumns="False"<BR>                               
ShowGroupPanel="False" 
<BR>                               
x:Name="dgg" 
<BR>                               
Margin="0"<BR>                               
ScrollMode="RealTime" 
<BR>                               
DataLoadMode="Synchronous" 
<BR>                               
EnableRowVirtualization="True"<BR>                               
RowIndicatorVisibility="Collapsed"<BR>                               
EditTriggers="CellClick"<BR>                               
BorderThickness="1" 
<BR>                               
ShowColumnFooters="True"<BR>                                
><BR>                
<telerik:RadGridView.Columns><BR>                    
<telerik:GridViewDataColumn DataMemberBinding="{Binding 
c_sort,Mode=TwoWay}"<BR>                                            
Header="sort"<BR>                                            
Width="40"<BR>                                            
IsReadOnly="True"<BR>                                            
TextWrapping="Wrap" 
/><BR>                    
<Rad:EnjoyItCombinSelTempelteColumn DataMemberBinding="{Binding 
c_gcode,Mode=TwoWay}"<BR>                                                     
Header="code"<BR>                                                     
IsReadOnly="False"<BR>                                                     
SelectType="SLGds"<BR>                                                     
EditValue="c_gcode"<BR>                                                     
UniqueName="c_gcode"<BR>                                                     
Width="100"<BR>                                                     
TextWrapping="Wrap"<BR>              
FooterTextAlignment="Center"><BR>                        
<Rad:EnjoyItCombinSelTempelteColumn.Footer><BR>                            
<TextBlock Text="sum:" HorizontalAlignment="Center" 
/><BR>                        
</Rad:EnjoyItCombinSelTempelteColumn.Footer><BR>                    
</Rad:EnjoyItCombinSelTempelteColumn></P>
<P>                    
<Rad:EnjoyItDataGridTextColumn Header="name" 
<BR>                                             
Width="170"<BR>                                             
IsReadOnly="True"<BR>                                             
DataMemberBinding="{Binding 
c_name,Mode=OneWay}"><BR>                    
</Rad:EnjoyItDataGridTextColumn></P>
<P>                    
<Rad:EnjoyItDataGridTextColumn Header="barcode" 
<BR>                                             
Width="110" 
<BR>                                             
IsReadOnly="True"<BR>                                             
DataMemberBinding="{Binding 
c_barcode,Mode=TwoWay}"><BR>                    
</Rad:EnjoyItDataGridTextColumn><BR>                    
<Rad:EnjoyItTextRoomNumColumn Header="num" TextAlignment="Right" 
<BR>                                             
Width="80"<BR>                                             
FooterTextAlignment="Right"<BR>                                             
DataMemberBinding="{Binding c_number,Mode=TwoWay,Converter={StaticResource 
DecimalConvert}}"><BR>                        
<telerik:GridViewDataColumn.AggregateFunctions><BR>                            
<telerik:SumFunction Caption="sum:" ResultFormatString="{}{0:#,###.00}" 
SourceField="c_number" 
/><BR>                        
</telerik:GridViewDataColumn.AggregateFunctions><BR>                        
<telerik:GridViewDataColumn.Footer><BR>                            
<telerik:AggregateResultsList ItemsSource="{Binding}" 
VerticalAlignment="Center" 
Grid.Column="4"><BR>                                
<ItemsControl.ItemTemplate><BR>                                    
<DataTemplate><BR>                                        
<TextBlock VerticalAlignment="Center"  HorizontalAlignment="Right" 
Text="{Binding FormattedValue, StringFormat=n}" 
TextAlignment="Right"/><BR>                                    
</DataTemplate><BR>                                
</ItemsControl.ItemTemplate><BR>                            
</telerik:AggregateResultsList><BR>                        
</telerik:GridViewDataColumn.Footer><BR>                    
</Rad:EnjoyItTextRoomNumColumn><BR></telerik:RadGridView.Columns><BR>            
</Rad:CEnjoyRadDataGrid></P></CODE>

5 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 29 Dec 2011, 11:03 AM
Hi,

I guess that you are following our online example about printing. You may extend the CreateDocument(RadGridView grid) method to print the aggregates like so:

if (grid.ShowColumnFooters)
            {
                TableRow footerRow = new TableRow();
  
                for (int j = 0; j < columns.Count(); j++)
                {
                    TableCell cell = new TableCell();
  
                   string value = "";
  
                    foreach (AggregateFunction f in columns[j].AggregateFunctions)
                    {
                       value += grid.AggregateResults[f.FunctionName].Caption + grid.AggregateResults[f.FunctionName].FormattedValue.ToString();
                    }
  
                    AddCellValue(cell, value);
  
                    cell.PreferredWidth = newTableWidthUnit((float)columns[j].ActualWidth);
                    cell.Background = SystemColors.MenuColor;
  
                    footerRow.Cells.Add(cell);
                }
  
                table.Rows.Add(footerRow);

I believe that this is what you need.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Shirley
Top achievements
Rank 1
answered on 31 Dec 2011, 06:31 AM
Thanks a lot, it works!
Another Question: when I scroll the horizontal scroll bar, sometime the data in the DataGrid will lost. The lost data just don't display in the DataGrid, it exists in the datasource of the DataGrid.
Can you give me any suggestion?
Thanks in advance.
Shirley
0
Pavel Pavlov
Telerik team
answered on 02 Jan 2012, 10:17 AM
Hi Shirley Zhao ,

Can you please verify if the issue still exists with the latest official version ?

Greetings,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Shirley
Top achievements
Rank 1
answered on 04 Jan 2012, 06:13 AM
Hi Pavel Pavlov,
Could you tell me in which version the problem has fixed? I tried the patch RadControls_for_Silverlight_4_2011_1_0419_Dev_hotfix, it still not work.
Thanks in advance.
Shirley Zhao
0
Shirley
Top achievements
Rank 1
answered on 09 Jan 2012, 10:46 AM
oops~,it work
Tags
General Discussions
Asked by
Shirley
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Shirley
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or