Grouping and Descriptors

2 posts, 0 answers
  1. Prashu
    Prashu avatar
    17 posts
    Member since:
    May 2013

    Posted 19 Oct 2013 Link to this post

    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

  2. Matt
    Matt avatar
    14 posts
    Member since:
    May 2012

    Posted 22 Oct 2013 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top