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

Urgent: How do I add group footer for total in a table.

2 Answers 804 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Somesh
Top achievements
Rank 1
Somesh asked on 23 Aug 2012, 01:15 PM
I have urgent requirement to make a automated reporting system and I am trying to create a report programmatically using telerik reporting.
So, far I was able to create group but not able to add group footer so that I can show sum, avg etc.
My code is:
 Telerik.Reporting.TextBox txtGroupHeader = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox txtGroupTotal;// = new Telerik.Reporting.TextBox();
            toggleVisibilityAction1 = new Telerik.Reporting.ToggleVisibilityAction();


            txtGroupHeader.Action = toggleVisibilityAction1;
            toggleVisibilityAction1.DisplayExpandedMark = false;


            // Required for telerik Reporting designer support


            InitializeComponent();


            TableGroup group = new TableGroup();
            Telerik.Reporting.TableGroup tableGroup4 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.TableGroup tableGroup5 = new Telerik.Reporting.TableGroup();
            group.Name = "Season";
            group.Groupings.AddRange(new Telerik.Reporting.Grouping[] {
            new Telerik.Reporting.Grouping("=Fields.Season")});
            group.Sortings.AddRange(new Telerik.Reporting.Sorting[] {
            new Telerik.Reporting.Sorting("=Fields.Season", Telerik.Reporting.SortDirection.Asc)});


            txtGroupHeader.Name = "txtGroupHeader";
            txtGroupHeader.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Cm(3.9314577579498291D),  Telerik.Reporting.Drawing.Unit.Cm(0.43585944175720215D));<br>
            txtGroupHeader.Style.BackgroundColor = System.Drawing.Color.Red;
            txtGroupHeader.Style.BorderStyle.Bottom = Telerik.Reporting.Drawing.BorderType.Solid;
            txtGroupHeader.Style.Color = System.Drawing.Color.White;
            txtGroupHeader.Style.Font.Bold = true;
            txtGroupHeader.StyleName = "";
            txtGroupHeader.Value = "=Fields.Season";
            tableGroup4.Groupings.AddRange(new Telerik.Reporting.Grouping[] {
            new Telerik.Reporting.Grouping(null)});
            group.Sortings.AddRange(new Telerik.Reporting.Sorting[] {
            new Telerik.Reporting.Sorting("=Fields.Season", Telerik.Reporting.SortDirection.Asc)});
            tableGroup4.Name = "Details";
            tableGroup5.Name = "Group1s";
            //group.ChildGroups.Add(tableGroup4);
            //group.ChildGroups.Add(tableGroup5);
            //this.table1.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(Telerik.Reporting.Drawing.Unit.Cm(1)));<br>
            this.table1.Corner.SetCellContent(0, 0, txtGroupHeader);
            this.table1.Items.Add(txtGroupHeader);
            group.ReportItem = txtGroupHeader;
            //Remove the detail group
            TableGroup detailGroup = table1.RowGroups[0];
            table1.RowGroups.Clear();
            //detailGroup.Visible = false;
            toggleVisibilityAction1.Targets.AddRange(new Telerik.Reporting.IToggleVisibilityTarget[] {
            detailGroup});
            //Add the detail group as a child to the AgeGroup (nest it)
            group.ChildGroups.Add(detailGroup);
            table1.RowGroups.Add(group);
---------------------


I tried finding help with visual studio generated code but to no avail. Please help as it is urgent. 

2 Answers, 1 is accepted

Sort by
0
Ranjan
Top achievements
Rank 1
answered on 23 Aug 2012, 05:04 PM
I am having same problem. I gone through code generated by telerik report designer but it did not help. Please provide some code to do the same.
I have to apply group from code with group footer.
0
IvanY
Telerik team
answered on 28 Aug 2012, 01:18 PM
Hello Ranjan,

I have attached a very simple example that uses table grouping with footers which are used as subtotals. The table also has grand totals at the bottom. Check out the designer.cs file to see the code snippet regarding the table and its groupings.

There are a few things that you have to know in order to create such tables programmatically - for example a table group can be in a row group or in a column group; please also check the parent-child relationship of the table groups, how the groupings/sortings are added and how the different groups are represented as table groups. Additionally please note the two rowgroups and their children - for example tableGroup2 has two child groups, tableGroup3 and tableGroup4 - these groups represent the detail section and the footer section in the City group.

The easiest approach in your case would be to create the exact same table in the designer and after that to copy the code and alter it programmatically the way you want. If your report has some specific requirements or the above does not solve your issue, please elaborate.

Kind regards,
IvanY
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Somesh
Top achievements
Rank 1
Answers by
Ranjan
Top achievements
Rank 1
IvanY
Telerik team
Share this question
or