PageCount and PageNumber

Thread is closed for posting
12 posts, 0 answers
  1. Ilse-Dorle Zander-Kilian
    Ilse-Dorle  Zander-Kilian avatar
    18 posts
    Member since:
    Jan 2006

    Posted 05 May 2007 Link to this post

    Hello all,

    Can anyone give me an example of how to use the PageCount and PageNumber Build-In objects please.

    Thanks,

    JY
  2. surfer
    surfer avatar
    585 posts
    Member since:
    Jul 2003

    Posted 05 May 2007 Link to this post

    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.

  3. DevCraft banner
  4. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 07 May 2007 Link to this post

    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
  5. Feedback
    Feedback avatar
    15 posts
    Member since:
    May 2007

    Posted 03 Jun 2007 Link to this post

    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
  6. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 04 Jun 2007 Link to this post

    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
  7. Giannis
    Giannis avatar
    3 posts
    Member since:
    May 2005

    Posted 08 Jun 2007 Link to this post

    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.
  8. Vassil Petev
    Admin
    Vassil Petev avatar
    1765 posts

    Posted 08 Jun 2007 Link to this post

    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):
    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
  9. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 08 Sep 2009 Link to this post

    In the last version of telerik's control I can't see BeginRender ,BeginRenderPage , EndRender ... have those been removed?
  10. Michael Love
    Michael Love avatar
    49 posts
    Member since:
    Sep 2009

    Posted 16 Oct 2009 Link to this post

    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
  11. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 16 Oct 2009 Link to this post

    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.
  12. Pavan
    Pavan avatar
    18 posts
    Member since:
    Apr 2011

    Posted 06 Apr 2012 Link to this post

    is there any alternate way to find the page number in the detail section of the page
  13. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Apr 2012 Link to this post

    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
    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.
Back to Top
DevCraft banner