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

Basic Column Headers Repeating on Each Page

7 Answers 361 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 09 Jun 2011, 03:41 PM
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.

7 Answers, 1 is accepted

Sort by
0
IvanDT
Telerik team
answered on 10 Jun 2011, 01:20 PM
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
0
bash
Top achievements
Rank 1
answered on 10 Jun 2011, 07:45 PM
Thanks for this -
was looking for the same thing and this worked!
0
MarkSci
Top achievements
Rank 1
answered on 27 Sep 2012, 10:38 AM
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
0
Steve
Telerik team
answered on 28 Sep 2012, 12:43 PM
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 >

0
MarkSci
Top achievements
Rank 1
answered on 28 Sep 2012, 01:01 PM
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
0
MarkSci
Top achievements
Rank 1
answered on 28 Sep 2012, 01:24 PM
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
0
Steve
Telerik team
answered on 01 Oct 2012, 04:43 PM
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!

Tags
General Discussions
Asked by
Philip
Top achievements
Rank 1
Answers by
IvanDT
Telerik team
bash
Top achievements
Rank 1
MarkSci
Top achievements
Rank 1
Steve
Telerik team
Share this question
or