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

Grouping and Descriptors

1 Answer 351 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Prashu
Top achievements
Rank 1
Prashu asked on 19 Oct 2013, 02:38 PM
Hi All,
Here is the situation for me.
 
I have Profit and loss report

My Requirement is shown in Attachment .. Please go through Grouping.png and come here

for "Totals"  Template i calling in code behind as 

 if (e.Column.UniqueName == "Account_No")
                            {
                                e.Column.Width = 120;
                                e.Column.HeaderTextAlignment = TextAlignment.Left;
                                var dataColumn = e.Column as GridViewDataColumn;
                                dataColumn.DataFormatString = "{0:N2}";
                                e.Column.TextAlignment = TextAlignment.Center;
                                if (i == 1)
                                {
                                    e.Column.GroupFooterTemplate = (DataTemplate)VReportViewer.Resources["GroupFooterRowTemplate"];
                                }

                            }
the string  "Totals" is Print after every Group using "ColumnGroupDescriptor " and  i'm grouping using below code

  if (this.ReportName == "Profit and Loss")
                        {
                           if (VReportViewer.GrdReport.Columns.Count == 9)
                                     { 
                                Telerik.Windows.Controls.GridView.ColumnGroupDescriptor descriptor = new ColumnGroupDescriptor();
                                descriptor.Column = VReportViewer.GrdReport.Columns["Account_Type"];

                                SumFunction sum = new SumFunction();
                                ((GridViewDataColumn)VReportViewer.GrdReport.Columns["Amount"]).AggregateFunctions.Add(sum);
                                sum.ResultFormatString = "{0:c2}";
  VReportViewer.GrdReport.GroupDescriptors.Add(descriptor);
}
}

and the Next Challenge I need to Group  next level i'm showing  example in attachment Please Help me to get these things
Gothrough Grouping2.png

1 Answer, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 22 Oct 2013, 03:24 PM
Grouping should be easy permitting your data is hierarchical.  For example your original item has a collection of items on it etc..Grids and subgrids kind of need that...but if your data is right something like this should work at each layer:

Grouping:
<telerik:RadGridView.GroupDescriptors>
                <telerik:GroupDescriptor x:Name="groupDescriptor" Member="Value using to group by here" SortDirection="Ascending"/>
            </telerik:RadGridView.GroupDescriptors>

Formatting the Group:
<telerik:RadGridView.GroupHeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Header, StringFormat=''}" Margin="0,0,50,0"/>
                </DataTemplate>
            </telerik:RadGridView.GroupHeaderTemplate>

Footer on column where 'Total' should show up:
<telerik:GridViewDataColumn.Footer>
                       <TextBlock Text="Total" FontWeight="Bold" HorizontalAlignment="Left"/>
                   </telerik:GridViewDataColumn.Footer>

Footer where total value is:
<telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:SumFunction SourceField="Source Field Here" ResultFormatString="{}{0:c0}"/>
                    </telerik:GridViewDataColumn.AggregateFunctions>


Should be able to do all this in the XAML and not in the code behind or any special behavior.  Hope that helps.
Tags
GridView
Asked by
Prashu
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Share this question
or