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

Dynamic table creation with GroupHeaders/Footers, Subtotals and totals

1 Answer 143 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
kenneyy kenn
Top achievements
Rank 1
kenneyy kenn asked on 22 Nov 2012, 09:44 AM

As a feasibility study on whether the Telerik Reporting control is fit for our purpose, we're trying to create the above and have downloaded / tweaked some sample code from this forum but the final solution is not getting us where we want to be.

I want to add columns to a table object at runtime
  • the table will have
    • column headers
    • groups
      • each group will have a
        • group header
        • group footer and
        • a subtotals column (on a quantity column)

The core of the code is shown below

The group headers / footers are NOT displaying - once this is accomplished the rest should be easy 

Telerik gods we beg you, please tell us what we're doing wrong!!!


//DataSet passed in as parameter


foreach (DataColumn dc in reportDS.Tables[0].Columns)



//Add table column group


TableGroup tableGroup1 = new Telerik.Reporting.TableGroup();



new Sorting(grpTitle1, SortDirection.Asc));

tableGroup1.Name =







//tableGroup1.Groupings.Add(new Grouping());



#region Grouping



if (!groupingAdded)



Group group = new Group();

Grouping groupExpression = new Grouping(grpTitle1);




new Telerik.Reporting.Sorting(grpTitle1, Telerik.Reporting.SortDirection.Asc));

group.GroupHeader =


new GroupHeaderSection();

group.GroupHeader.Height =


new Unit(10.0, UnitType.Mm);

group.GroupHeader.Style.BackgroundColor =





TextBox tbxGroupHdr = new Telerik.Reporting.TextBox();

tbxGroupHdr.Value =


"=" + grpTitle1;

tbxGroupHdr.Size =


new SizeU(new Unit(10, UnitType.Mm), new Unit(30.0, UnitType.Mm));


group.GroupFooter =


new GroupFooterSection();

group.GroupFooter.Height =


new Unit(10.0, UnitType.Mm);

group.GroupFooter.Style.BackgroundColor =





TextBox tbxGroupFtr = new Telerik.Reporting.TextBox();

tbxGroupFtr.Value =


"Group Footer";

tbxGroupFtr.Size =


new SizeU(new Unit(10, UnitType.Mm), new Unit(30.0, UnitType.Mm));




groupingAdded =







//Add table body column


//this.table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Unit.Inch(1)));

txtColumnHdr =


new Telerik.Reporting.HtmlTextBox();

SetTextboxStyle(count, columnCount, dc.ColumnName, fntHdr,


TextBoxType.Group, ref txtColumnHdr);

tableGroup1.ReportItem = txtColumnHdr;




txtColumnBdy =



new Telerik.Reporting.HtmlTextBox();

SetTextboxStyle(count, columnCount, dc.ColumnName, fntBdy,


TextBoxType.Item, ref txtColumnBdy);


this.table1.Body.SetCellContent(0, i++, txtColumnBdy);


this.table1.Items.AddRange(new ReportItemBase[] { txtColumnHdr, txtColumnBdy });



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 27 Nov 2012, 12:21 PM
Hi Kenneyy,

As a best practice we can recommend you to use the designer to create the tables that later you are going to create programmatically. Once you have done this you can check the code behind file to see the code serialized. Additionally you can create your tables step by step and check the code after each step to see what is generated.

Regarding your issue - in general you have to create the parent group and add to it as child groups the header, footer and your main group and then add this parent group to the row groups of the table (the code that you have provided does not do that, or at least it does not contain such code). Therefore just create a simple Crosstab with the designer and add the respective group with header and footer; then check the designer.cs file to see the code generated.

Kind regards,
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

General Discussions
Asked by
kenneyy kenn
Top achievements
Rank 1
Answers by
Telerik team
Share this question