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

group and sum in run time(urgent)

1 Answer 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mahendra
Top achievements
Rank 1
Mahendra asked on 18 Feb 2011, 11:49 AM
Hi

i have created the report in the run time but i have not able to create the group and sum
so i want to know How to create the report in run time with group and sum.

if possible please provide some sample code
it will highly appriciated

Thanks in advance


Mahendra

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 22 Feb 2011, 12:06 PM
Hi Mahendra,

We highly recommend creating the desired groups through the Report Designer first and then review the code in the InitializeComponent() to see the internal structure. Check out the following code snippet that shows in general how to add groups programmatically. We are not sure about your specific scenario, thus this is just a sample code:

var group1 = new Telerik.Reporting.Group();
var groupFooterSection1 = new Telerik.Reporting.GroupFooterSection();
var groupHeaderSection1 = new Telerik.Reporting.GroupHeaderSection();
var textBox1 = new Telerik.Reporting.TextBox();
//
// group1
//
group1.GroupFooter = groupFooterSection1;
group1.GroupHeader = groupHeaderSection1;
group1.Groupings.Add("=Fields.Manufacturer");
group1.Name = "group1";
//
// groupHeaderSection1
//
groupHeaderSection1.Height = new Telerik.Reporting.Drawing.Unit(0.7D, Telerik.Reporting.Drawing.UnitType.Inch);
groupHeaderSection1.Name = "groupHeaderSection1";
//
// textBox1
//
textBox1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(4D), Telerik.Reporting.Drawing.Unit.Inch(0.2D));
textBox1.Name = "textBox1";
textBox1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.8D), Telerik.Reporting.Drawing.Unit.Inch(0.2D));
textBox1.Value = "=Sum(Fields.Sales)";
textBox1.Style.BackgroundColor = Color.Aqua;
//
// groupFooterSection1
//
groupFooterSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(0.7D);
groupFooterSection1.Items.Add(textBox1);
groupFooterSection1.Name = "groupFooterSection1";
this.Groups.Add(group1);
 
this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
detail,
groupHeaderSection1,
groupFooterSection1});

Kind regards,
Peter
the Telerik team
Tags
General Discussions
Asked by
Mahendra
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or