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

Report grouping not applied

1 Answer 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Corporate Information Services
Top achievements
Rank 1
Corporate Information Services asked on 25 Nov 2011, 05:50 PM
I am currently trialing the Telerik reporting tool.
I have successfully created a cross tab report which is fine as long as I don't set the data source at runtime.
If I set the data source at runtime the report loses its groupings.

I have tried setting the grouping again in code but it makes no difference.
Could someone please tell me what I am doing wrong?

Cheers

Jason

Code
            OCMBusinessLogic logic = new OCMBusinessLogic();
            IList<AOSMatrix> matrixdata = null;


            matrixdata = logic.GetAOSMatrix("11/12", "ba_eng");


            MessageBox.Show("Rows " + matrixdata.Count.ToString());


            AOSModuleMatrix rpt = null;
            rpt = new AOSModuleMatrix();
            rpt.ReportParameters["ReportTitle"].Value = "Programme matrix for [programme family]";


            Telerik.Reporting.Group grp = new Telerik.Reporting.Group();
            grp.Name = "AOS";
            grp.Groupings.Add(new Telerik.Reporting.Data.Grouping("=Fields.AOScode"));
            rpt.Groups.Add(grp);
            rpt.DataSource = matrixdata;


            ReportProcessor reportProcessor = new ReportProcessor();
            Hashtable deviceinfo = new Hashtable();
            deviceinfo["FontEmbedding"] = "Subset";
            RenderingResult result = reportProcessor.RenderReport("PDF", rpt, deviceinfo);


            FileStream fs = new FileStream("c:\\telerik.pdf", FileMode.Create);
            fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            fs.Flush();
            fs.Close();


            MessageBox.Show("Generated");

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 28 Nov 2011, 06:26 PM
Hi Corporate Information Services,

The code you provided seems correct. The only thing is that you do not create group header and group footer and if the data is ordered the same way before and after the grouping, there would be no visual difference.

The best way to sort this out would be to create the groupings in the Designer and then check the auto-generated code in the myReport.Designer.cs. 

All the best,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Corporate Information Services
Top achievements
Rank 1
Answers by
Elian
Telerik team
Share this question
or