Basic Column Headers Repeating on Each Page

8 posts, 0 answers
  1. Philip
    Philip avatar
    70 posts
    Member since:
    Apr 2008

    Posted 09 Jun 2011 Link to this post

    I have a question, that seems extremely simple, but I can not seem to figure it out. I have created a basic report and simply added a datasource. I have a list of parts, and I would like for the column headers to repeat on each page, not on each line. If I put the column headers in the details section, they repeat on every row. If I put them in the page header, they then appear above the report header.

    How can I simply put the column headers below the report header, and have the repeat on each page. Seems like I need to add a second page header, but have it below the report header.

    I am doing this through the GUI also.
  2. IvanDT
    Admin
    IvanDT avatar
    76 posts

    Posted 10 Jun 2011 Link to this post

    Hello Philip,

    The thing you need is unbound group (group without grouping criteria). You can add your column headers in the GroupHeaderSection and because the PrintOnEveryPage property default state is True, your column header will appear on every page. You can also view the following articles in our help documentation:
    All the best,
    IvanDT
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. bash
    bash avatar
    13 posts
    Member since:
    Jul 2009

    Posted 10 Jun 2011 Link to this post

    Thanks for this -
    was looking for the same thing and this worked!
  5. MarkSci
    MarkSci avatar
    16 posts
    Member since:
    Dec 2011

    Posted 27 Sep 2012 Link to this post

    Could you please provide an example of this where the column headers are created entirely within the code-behind?

    I have created a GroupHeaderSection which contains a panel in which my column headers are defined. I then add the GroupHeaderSection to my report.

    I then create a DetailSection which also contains a panel containing my data. I then add this DetailSection to my report. The code is displayed below:

    // Create the Group Header Section
    GroupHeaderSection GroupHeader = new GroupHeaderSection();
    GroupHeader.Height = new Telerik.Reporting.Drawing.Unit(20, Telerik.Reporting.Drawing.UnitType.Pixel);
    GroupHeader.Name = "GroupHeader";
    Report1.Items.Add((ReportItemBase)GroupHeader);
    // Create the Panel to hold the Activity Headers and add to the report
    Telerik.Reporting.Panel panelColumnHeaders = CreateActivityColumnHeaderPanel();
    GroupHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { panelColumnHeaders });
    // Create the Detail Section
    DetailSection detail = new DetailSection();
    detail.Height = new Telerik.Reporting.Drawing.Unit(20, Telerik.Reporting.Drawing.UnitType.Pixel);
    detail.Name = "Detail";
    Report1.Items.Add((ReportItemBase)detail);
    // Create the Panel to hold the Activity Data and add to the report
    Telerik.Reporting.Panel panelActivities = CreateActivityDataPanel();            
    detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { panelActivities });

    When I run the report, the data is displayed but there are no column headers. I thought that I may need to add the DetailSection to the GroupHeaderSection but this generates an error.

    Many thanks

    Mark
  6. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 28 Sep 2012 Link to this post

    Hi Mark,

    A group consists of both group header and group footer and it is mandatory to add both, if you're not going to use the footer, you can set its Visible property to false. It would be easy to spot whether your section is rendered or not if you set a more contrasting background color to it, as by default it is white, which matches with the report background.

    Generally the easiest way to learn our API, especially when you're not sure how to accomplish something, is to create the desired layout through the Report Designer, then open the InitializeComponent method and scan through the code it has generated.

    Kind regards,
    Steve
    the Telerik team

    BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

  7. MarkSci
    MarkSci avatar
    16 posts
    Member since:
    Dec 2011

    Posted 28 Sep 2012 Link to this post

    HI Steve,

    I understand that a footer is required however I am still no clearer about implementing this. As you will see from my code I do not have a group. I presume that I need to create a group object, and then attach the footer and header sections to that group. How do I do this programatically? I can't find anywhere within the documentation where this is done (although I have found many references to 'unbound' groups there are never any examples to go with it).

    Also, how does the detail relate to the group? In the example I have given, would the detail remain separate and be added to the report object or should it be added to the group object?

    If there is any way that you could amend the code that would be useful.

    I understand why you advocate the report designer, but my source data is quite complex (an IEnumerable data service call) which is not possible to bind design time. If I could make this task any easier, I would do!

    Cheers

    Mark
  8. MarkSci
    MarkSci avatar
    16 posts
    Member since:
    Dec 2011

    Posted 28 Sep 2012 Link to this post

    When I try to create a group programatically as shown in my attached code, I get the error: "It is not allowed to add DetailSection to GroupFooter (Telerik.Reporting.GroupHeaderSection)".

    // Create the Group Header Section
    GroupHeaderSection GroupHeader = new GroupHeaderSection();
    GroupHeader.Height = new Telerik.Reporting.Drawing.Unit(20, Telerik.Reporting.Drawing.UnitType.Pixel);
    GroupHeader.Name = "GroupHeader";
    //Report1.Items.Add((ReportItemBase)GroupHeader);
    // Create the Group Footer Section
    GroupFooterSection GroupFooter = new GroupFooterSection();
    GroupHeader.Height = new Telerik.Reporting.Drawing.Unit(20, Telerik.Reporting.Drawing.UnitType.Pixel);
    GroupHeader.Name = "GroupFooter";
    GroupHeader.Style.BackgroundColor = System.Drawing.Color.LightBlue;
    //Report1.Items.Add((ReportItemBase)GroupFooter);
    // Create the Panel to hold the Activity Headers and add to the report
    Telerik.Reporting.Panel panelColumnHeaders = CreateActivityColumnHeaderPanel();
    GroupHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { panelColumnHeaders });
    // Create the Detail Section
    DetailSection detail = new DetailSection();
    detail.Height = new Telerik.Reporting.Drawing.Unit(20, Telerik.Reporting.Drawing.UnitType.Pixel);
    detail.Name = "Detail";
    //Report1.Items.Add((ReportItemBase)detail);
    Telerik.Reporting.Group oGroup = new Telerik.Reporting.Group();
    oGroup.GroupFooter = GroupFooter;
    oGroup.GroupHeader = GroupHeader;
    oGroup.Groupings.AddRange(new Telerik.Reporting.Grouping[] { new Telerik.Reporting.Grouping("") });
    oGroup.Name = "Group";
    oGroup.GroupHeader.Items.Add(detail);

    ...All I am trying to do is add headers to my report. Why is this seemingly routine task so difficult?

    Thanks

    Mark
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 01 Oct 2012 Link to this post

    Hi Mark,

    It is wrong to add detail section to group header section, these sections are not self inclusive and you can only add report items to report sections.
    The following two lines would be the correct finish of adding the group to your report:

    myreport.Groups.AddRange(new Telerik.Reporting.Group[] {oGroup});
    myreport.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { GroupHeader, GroupFooter });

    You can very quickly see this structure if you create a group from the report designer.

    Also note that in your sample code below you're using GroupHeader for the GroupFooter properties as well, probably innocent mistake for the example.

    Kind regards,
    Steve
    the Telerik team

    HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Back to Top
DevCraft banner