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

Dynamic Report Add Sum Field

1 Answer 190 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
burk
Top achievements
Rank 1
burk asked on 29 Jul 2015, 01:18 PM

Hello,

 

I create a Report on runtime with ;

 

for (int i = 0; i <= ds.Tables[0].Columns.Count - 1; i++)
            {
                var tableGroupColumn = new TableGroup();
                tableGroupColumn.Name = i.ToString();
                table1.ColumnGroups.Add(item: tableGroupColumn);
 
                txtGroup = new HtmlTextBox
                               {
                                   Size = new SizeU(Unit.Inch(2.1), Unit.Inch(0.3)),
                                   Value = ds.Tables[0].Columns[i].ColumnName,
                                   Style =
                                       {
                                           BackgroundColor = System.Drawing.Color.FromArgb(59,100,141),
                                           Color = System.Drawing.Color.White,
                                           BorderStyle = { Default = BorderType.Solid },
                                           TextAlign = HorizontalAlign.Center,
                                           VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle,
                                           BorderColor = { Default = Color.Black }
                                       },
                                   StyleName = "Corporate.TableHeader",
                               };
                tableGroupColumn.ReportItem = txtGroup;
 
                txtTable = new HtmlTextBox()
                               {
                                   Size = new SizeU(Unit.Inch(2.2), Unit.Inch(0.3)),
                                   Value = "=Fields.[" + ds.Tables[0].Columns[i].ColumnName + "]",
                                   //Value = data.Rows[rowIndex][i].ToString(),
                                   Style =
                                       {
                                           BorderStyle = { Default = BorderType.Solid },
                                           TextAlign = HorizontalAlign.Center,
                                           VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle,
                                           BorderColor = { Default = Color.Black }
                                       },
                                       StyleName = "Corporate.TableHeader",
                               };
 
                table1.Body.SetCellContent(0, columnIndex: i, item: txtTable);
                //rowIndex++;
                table1.Items.AddRange(items: new ReportItemBase[] { txtTable, txtGroup });
            }

and i want to add a Total with sum function but i cant do this.

1 Answer, 1 is accepted

Sort by
0
Accepted
Nasko
Telerik team
answered on 03 Aug 2015, 10:14 AM
Hello Baran,

It is possible to create your table total dynamically, but this is no trivial matter. In general, the fastest way to do this is to create the table definition with the totals in the Visual Studio Report Designer and use the automatically generated code in Designer.cs file as a template for dynamic table generation. You may also find useful the Programmatic Control of Reports help articles on the topic and the Reporting API Reference.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
burk
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or