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

Programatically Grouping

1 Answer 410 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Master
Top achievements
Rank 1
Master asked on 16 Jun 2008, 12:57 PM
Hi, the presentation layer of my reporting model is XML based. The things (data and Formating) are working well except the groups, Unable to display and group data. I have written a ReportVisitor that parse the XML and transform it for the Telerik expected objects. Given Below is the source for Group and the XML.

public override void VisitGroup(Group element)
        {
            Telerik.Reporting.Group HeaderGroup = new Telerik.Reporting.Group(); 
            Telerik.Reporting.GroupHeaderSection HeaderGroupSection = new GroupHeaderSection();
            Telerik.Reporting.GroupFooterSection FooterGroupSection = new GroupFooterSection();
           
            HeaderGroup.GroupHeader= HeaderGroupSection ;
            HeaderGroup.GroupFooter = FooterGroupSection ;
            HeaderGroup.Grouping.AddRange(new Telerik.Reporting.Data.Grouping[] {new Telerik.Reporting.Data.Grouping("=Fields.[" + element.Column + "]")});
            this.currentContainer.Report.Groups.Add(HeaderGroup);           
            this.currentContainer = HeaderGroupSection;
           
            element.Header.Accept(this);
           
            if (HeaderGroupSection != null)
                {
                    CalculateMaxHeight(HeaderGroupSection);
                    HeaderGroupSection.PrintOnEveryPage = true;
                    HeaderGroupSection.KeepTogether = true;
                    HeaderGroupSection.PageBreak = PageBreak.None;
                }

            this.currentContainer = FooterGroupSection;
            element.Footer.Accept(this);
           
            if (FooterGroupSection != null)
                {
                    CalculateMaxHeight(FooterGroupSection);
                    FooterGroupSection.KeepTogether = true;
                    FooterGroupSection.PageBreak = PageBreak.None;
               
                }

            this.currentContainer = this.currentContainer.Report;
}

------------------------------------------------------------

 <group level="1" column="Email" newpage="true">
          <groupHeader width="5000" height="70">
            <boundField id="boundField#" datafield="Email" left="0" top="2" width="300" height="30" wrap="false" formatString="" textalign="left" cssclass="GroupTitle" borderwidth="" borderstyle="" bordercolor="black"/>
            <label id="label#" text="Some Heading" left="0" top="32" width="35" height="21" wrap="true" formatString="" textalign="left" cssclass="Header" borderwidth="" borderstyle="" bordercolor="" fontfamily="Arial" fontsize="11px" fontweight="bold"/>
          </groupHeader>
          <groupFooter width="950" height="35">
            <runningTotal text="Count" expression="count(property)" datatype="System.Int" reset="true" resetvalue="0" left="370" top="5" width="100" height="21" wrap="false" formatString="{0:N0}" textalign="right" cssclass="GroupTitle" borderwidth="" borderstyle="" bordercolor="" />
          </groupFooter>
        </group>

1 Answer, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 18 Jun 2008, 08:46 AM
Hi,

Looking at your code, the only thing I noticed is that you never add the GroupHeader/FooterSections to the report's Items collection. Adding one Group to the Report.Groups collection just sets the grouping criteria for the current report but you have to "register" the group sections as well.

Here is a sample:
// register group1 
this.Groups.AddRange(new Telerik.Reporting.Group[] { 
            this.group1}); 
 
// register the report sections including the two group1's sections 
this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { 
            this.groupHeaderSection1, 
            this.groupFooterSection1, 
            this.pageHeader, 
            this.detail}); 

Please note that the order of adding sections to the Report.Items collection usually doesn't matter.

In case you are still having troubles with the groups, the first thing you can do is to try creating a similar report with the Report Designer inside Visual Studio and examine the code that the designer has generated. This is the InitializeComponent() method that usually resides in the designer source file (ex.: MyReport1.Designer.cs).

Kind regards,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Master
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Share this question
or