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)
- each group will have a
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();
tableGroup1.Sortings.Add(
new Sorting(grpTitle1, SortDirection.Asc));
tableGroup1.Name =
Group1";
//tableGroup1.Groupings.Add("1=1");
//tableGroup1.Groupings.Add(new Grouping());
tableGroup1.Groupings.Add(grpTitle1);
this.table1.ColumnGroups.Add(tableGroup1);
#region Grouping
if (!groupingAdded)
{
Group group = new Group();
Grouping groupExpression = new Grouping(grpTitle1);
group.Groupings.Add(groupExpression);
group.Sortings.Add(
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 =
Color.LightSteelBlue;
Telerik.Reporting.
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.GroupHeader.Items.Add(tbxGroupHdr);
group.GroupFooter =
new GroupFooterSection();
group.GroupFooter.Height =
new Unit(10.0, UnitType.Mm);
group.GroupFooter.Style.BackgroundColor =
Color.LightYellow;
Telerik.Reporting.
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));
group.GroupFooter.Items.Add(tbxGroupFtr);
this.table1.Report.Groups.Add(group);
groupingAdded =
true;
}
#endregion
//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 });
count++;
}