This question is locked. New answers and comments are not allowed.
Ilse-Dorle Zander-Kilian
Top achievements
Rank 1
Ilse-Dorle Zander-Kilian
asked on 05 May 2007, 03:58 PM
Hello all,
Can anyone give me an example of how to use the PageCount and PageNumber Build-In objects please.
Thanks,
JY
Can anyone give me an example of how to use the PageCount and PageNumber Build-In objects please.
Thanks,
JY
11 Answers, 1 is accepted
0
surfer
Top achievements
Rank 1
answered on 05 May 2007, 05:04 PM
If you have installed the Q1 2007 release, you will be able to review the documentation and namely the Using Report Events section. There you can find an example how to bind the current PageNumber to a TextBox control on the page in the, say, BeginRenderPage event.
e.g.
The Report object exposes these ten events:
Property Description
BeginRender Fires when the report is about to be rendered. Can be canceled.
BeginRenderPage Fires just before each page of the report is rendered. Can be canceled.
EndRender Fires when the report is completely rendered.
EndRenderPage Fires just after each page of the report is rendered.
ItemAdded Fires when each item is added to the report.
ItemCreated Fires when each item on the report is created.
ItemDataBinding Fires just before each report item is bound to data. Can be canceled.
ItemDataBound Fires just after each report item is bound to data.
ItemRemoved Fires when an item is removed from the report.
NeedDataSource Fires when the report does not have any valid data source bound to it.
For example, you can use the BeginRenderPage event to add page numbering to your reports:
private void EventsReport_NewPage(object sender, PageEventArgs e)
{
string text = string.Format("Page {0} of {1}", e.PageNumber, e.PageCount);
Processing.Report report = (Processing.Report)sender;
Processing.ReportItemBase[] items = report.Items.Find("txtPageNumber", true);
if (items.Length > 0)
{
Processing.TextBox pageNo = items[0] as Processing.TextBox;
if (null != pageNo)
{
pageNo.Text = text;
}
}
}
The BeginRenderPage and EndRenderPage events only fire when the current export format supports paging.
e.g.
The Report object exposes these ten events:
Property Description
BeginRender Fires when the report is about to be rendered. Can be canceled.
BeginRenderPage Fires just before each page of the report is rendered. Can be canceled.
EndRender Fires when the report is completely rendered.
EndRenderPage Fires just after each page of the report is rendered.
ItemAdded Fires when each item is added to the report.
ItemCreated Fires when each item on the report is created.
ItemDataBinding Fires just before each report item is bound to data. Can be canceled.
ItemDataBound Fires just after each report item is bound to data.
ItemRemoved Fires when an item is removed from the report.
NeedDataSource Fires when the report does not have any valid data source bound to it.
For example, you can use the BeginRenderPage event to add page numbering to your reports:
private void EventsReport_NewPage(object sender, PageEventArgs e)
{
string text = string.Format("Page {0} of {1}", e.PageNumber, e.PageCount);
Processing.Report report = (Processing.Report)sender;
Processing.ReportItemBase[] items = report.Items.Find("txtPageNumber", true);
if (items.Length > 0)
{
Processing.TextBox pageNo = items[0] as Processing.TextBox;
if (null != pageNo)
{
pageNo.Text = text;
}
}
}
The BeginRenderPage and EndRenderPage events only fire when the current export format supports paging.
0
Hi guys,
In v1 of Telerik Reporting the PageNumber and PageCount global variables are available only to items that reside in PageHeaderSection or PageFooterSection. In an item binding expression you can use them the same way as the data fields.
For example let's have a TextBox item named "pageTextBox" in the report's page footer. Setting its value with the following binding expression:
pageTextBox.Value = "=PageNumber + ' of ' + PageCount";
will show the following when the report is rendered:
1 of 10
2 of 10
...
As a working example of the PageNumber and PageCount global variables I suggest you to examine the accompanying sample solutions - there is an example named EventsReport that contains a TextBox - txtPageNumber - that displays the current page number.
Regarding the rendering events - these events were not intended to be public as they are subject to change in future versions. We are not sure how they made it into the help, but they will be removed and the API reference will show only the public API state in the upcoming service pack. We are sorry if this causes any inconvenience.
Kind regards,
Svetoslav
the telerik team
Instantly find answers to your questions at the new Telerik Support Center
In v1 of Telerik Reporting the PageNumber and PageCount global variables are available only to items that reside in PageHeaderSection or PageFooterSection. In an item binding expression you can use them the same way as the data fields.
For example let's have a TextBox item named "pageTextBox" in the report's page footer. Setting its value with the following binding expression:
pageTextBox.Value = "=PageNumber + ' of ' + PageCount";
will show the following when the report is rendered:
1 of 10
2 of 10
...
As a working example of the PageNumber and PageCount global variables I suggest you to examine the accompanying sample solutions - there is an example named EventsReport that contains a TextBox - txtPageNumber - that displays the current page number.
Regarding the rendering events - these events were not intended to be public as they are subject to change in future versions. We are not sure how they made it into the help, but they will be removed and the API reference will show only the public API state in the upcoming service pack. We are sorry if this causes any inconvenience.
Kind regards,
Svetoslav
the telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Feedback
Top achievements
Rank 1
answered on 03 Jun 2007, 07:15 AM
For me, it really does cause an inconvenience, because I would like to suppress certain things on certain pages, and there's no way I can get there without BeginRenderPage.
Is there any way to shrink the PageHeader section, but only on the last page of the report?
I want to display a chart on the last page of the report, and remove extra header information that doesn't need to be there.
Matthew
Is there any way to shrink the PageHeader section, but only on the last page of the report?
I want to display a chart on the last page of the report, and remove extra header information that doesn't need to be there.
Matthew
0
Hello Matthew,
The current version of Telerik Reporting doesn't allow changes of the Page Header/Footer Heights - this applies to Image/PDF rendering engines as well. Actually when rendering a report, the engine reserves the space for the page header and footer sections (if any), regardless of whether you render this section or not (both page sections have PrintOnFirstPage and PrintOnLastPage properties). Also the page sections cannot grow or shrink, and the items inside them cannot change their size and location.
The rendering engine first calculates the number of the pages and then renders the report items. Changing the size of a section will break the paging and will break the report viewer that needs to know the exact page count.
Now we're about to start the next version of Telerik Reporting and will consider implementing some kind of rendering events in case we're confident that this is reasonable and possible.
Best wishes,
Svetoslav
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The current version of Telerik Reporting doesn't allow changes of the Page Header/Footer Heights - this applies to Image/PDF rendering engines as well. Actually when rendering a report, the engine reserves the space for the page header and footer sections (if any), regardless of whether you render this section or not (both page sections have PrintOnFirstPage and PrintOnLastPage properties). Also the page sections cannot grow or shrink, and the items inside them cannot change their size and location.
The rendering engine first calculates the number of the pages and then renders the report items. Changing the size of a section will break the paging and will break the report viewer that needs to know the exact page count.
Now we're about to start the next version of Telerik Reporting and will consider implementing some kind of rendering events in case we're confident that this is reasonable and possible.
Best wishes,
Svetoslav
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Giannis
Top achievements
Rank 1
answered on 08 Jun 2007, 09:08 AM
Hello,
I am afraid I cannot find anything in the sample solution (appart from the txtPageNumber TextBox) that makes the page numbering work.
There doesn't seem to be any global variable named PageCount or PeageNumber in the EventsReport.cs file. In fact there is no variable named like that in the entire sample solution.
Any help?
Thanks in advance.
I am afraid I cannot find anything in the sample solution (appart from the txtPageNumber TextBox) that makes the page numbering work.
There doesn't seem to be any global variable named PageCount or PeageNumber in the EventsReport.cs file. In fact there is no variable named like that in the entire sample solution.
Any help?
Thanks in advance.
0
Hi Giannis,
We have answered your support ticket on the problem. Here is our answer:
There are two built-in objects (PageNumber and PageCount) that you can only use in item binding expressions. These can be used for items in the Page Header and/or Page Footer sections.
Here is a code snippet that will help you with this task (here we have a TextBox named textBoxPageNo which can reside either in the PageHeaderSection or PageFooterSection):
You can learn more about the item binding expression from the Telerik Reporting documentation. Here is the link to the online version of the help:
http://www.telerik.com/help/reporting/?DesigningReportsItemBindingExpressions.html
Sincerely yours,
Rob
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
We have answered your support ticket on the problem. Here is our answer:
There are two built-in objects (PageNumber and PageCount) that you can only use in item binding expressions. These can be used for items in the Page Header and/or Page Footer sections.
Here is a code snippet that will help you with this task (here we have a TextBox named textBoxPageNo which can reside either in the PageHeaderSection or PageFooterSection):
textBoxPageNo.Value = "='Page ' + PageNumber + ' of ' + PageCount";
You can learn more about the item binding expression from the Telerik Reporting documentation. Here is the link to the online version of the help:
http://www.telerik.com/help/reporting/?DesigningReportsItemBindingExpressions.html
Sincerely yours,
Rob
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Michele
Top achievements
Rank 2
answered on 08 Sep 2009, 10:19 AM
In the last version of telerik's control I can't see BeginRender ,BeginRenderPage , EndRender ... have those been removed?
0
Michael Love
Top achievements
Rank 1
answered on 16 Oct 2009, 05:57 AM
So, what would the syntax be when you enter this into the Expression Editor instead of code?
I keep getting an error that says it doesn't like the '+'
Thanks, Mike
I keep getting an error that says it doesn't like the '+'
Thanks, Mike
0
Hello Michael,
The same as my colleague posted but without the double quotes i.e.:
='Page ' + PageNumber + ' of ' + PageCount
Regards,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The same as my colleague posted but without the double quotes i.e.:
='Page ' + PageNumber + ' of ' + PageCount
Regards,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pavan
Top achievements
Rank 1
answered on 06 Apr 2012, 10:06 PM
is there any alternate way to find the page number in the detail section of the page
0
Hi Pavan,
You can use the built-in PageNumber and PageCount objects only in page sections. This information is available in the Understanding Report Sections help article.
All the best,
Steve
the Telerik team
You can use the built-in PageNumber and PageCount objects only in page sections. This information is available in the Understanding Report Sections help article.
All the best,
Steve
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.