Can not change Page break before a header in code

7 posts, 1 answers
  1. Fabrice
    Fabrice avatar
    8 posts
    Member since:
    Feb 2009

    Posted 06 Nov 2009 Link to this post

    I have a report like that
    groupheader1
        groupheader2
            detail
        groupfooter2
    groupfooter1

    for some groupheader2, i need a page break page.
    I write some code, like that :

     

            private void groupHeader2_ItemDataBinding(object sender, EventArgs e)  
            {  
                Telerik.Reporting.Processing.GroupSection headerAgent = (Telerik.Reporting.Processing.GroupSection)sender;  
                LinqEntityBaseLoan.ComAPayer com = headerAgent.DataObject.RawData as LinqEntityBaseLoan.ComAPayer;  
                headerAgent.Visible = com.Agent_ID != com.SuperAgent_ID;  
                if (headerAgent.Visible)  
                    this.groupHeaderAgent.PageBreak = PageBreak.Before;  
                else 
                    this.groupHeaderAgent.PageBreak = PageBreak.None;  
            } 

    but the result is that in the next printed header, the page break will occur.
    I try to change to headerAgent.PageBreak = PageBreak.Before but PageBreak is readonly. It seems that the ..Engine.ReportSection is created before Report.ReportSection (it is normal) and can not be changed (but visible can be !).

    After a long search, i created a fake group :
    groupheader1
        groupheader2fake
        groupheader2
            detail
        groupfooter2
        groupfooter2fake
    groupfooter1

    And write the event groupHeader2fake_ItemDataBinding.

    Is it normal to proceed like this ? A settable Break Page or an event before the creation of Engine.ReportSection can be usefull !


     

  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 10 Nov 2009 Link to this post

    Hello Fabrice,

    The PageBreaks are respected in the rendering stage (no events there) which is well after the processing of the report has finished and there is no control over the PageBreaks anymore. In fact we have not been contacted with such an inquiry before and would appreciate if you elaborate on your exact scenario so that we can understand whether you really need "conditional" page breaks or you can achieve similar behavior in some other manner.

    Kind 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.
  3. DevCraft banner
  4. Fabrice
    Fabrice avatar
    8 posts
    Member since:
    Feb 2009

    Posted 10 Nov 2009 Link to this post

    OK, page break are respected in the rendering phase, but when it constructs the Telerik.Report.Engine.* objects, the Page Break can not be changed in event.

    As the scenario (loop):
    1. Create groupheader1 & groupfooter1  Telering.Reporting.engine.ReportSection
    2. Call event on groupheader1 & groupfooter1  (the sender is the "engine" version, this is why we need to find children and not use this.cTextBox.Text="...."))
    3. Create groupheader2 & groupfooter2  Telering.Reporting.engine.ReportSection
    4. Call event on groupheader2 & groupfooter2  (..)
    ....

    => it creates a complex graph of engine object
    Final stage : rendering.

    (what i understand ;) ).

    My problem is that sometimes i want a Page break between groupheader1 & groupheader2 (based on values used to group header1 & header2 (1)), but the Page Break on the Telering.Reporting.engine.ReportSection is read only (and als you said, the rendering phase is later, i do not understand why it is read only !).

    (1) for my specific case, Group1 is grouped on MasterAgent, Group2 is grouped on Agent, when MasterAgent=Agent, no page break, when Master != Agent => page break.
  5. Answer
    Ivan
    Admin
    Ivan avatar
    111 posts

    Posted 10 Nov 2009 Link to this post

    Hello Fabrice,

    As stated in our previous reply, conditional page breaks are not supported at the present moment. We might consider implementing this feature for subsequent version, but we cannot give you an exact estimate date for now. Since we do not know your specific requirements we are not able to provide you with a valid workaround. Perhaps if you can figure out a way to implement your report without conditional page breaks this might solve your problem.

    Please excuse us for the inconvenience this limitation might be causing you.

    Greetings,
    Ivan
    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.
  6. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 26 Apr 2011 Link to this post

    Can I set the pagebreak of a header with a checkbox in the parameters?  When I try to add a binding to it and set it to ="Before" or ="None" it doesn't work
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 29 Apr 2011 Link to this post

    Hi danparker276,

    Note that when you use Bindings, you should ensure that you specify correct type for the Expression. For your case that type is Telerik.Reporting.PageBreak and specifying string instead would not work. You would have to create an User Function e.g.:
    Copy Code
    Public Shared Function DefinePageBreak(value As Integer) As PageBreak
        If value = 1 Then
            Return PageBreak.None
        Else
            Return PageBreak.Before
        End If
    End Function

    and add the Binding to your section:

    Property Path                Expression
    ====================================================
    PageBreak                    = DefinePageBreak(RowNumber())

    Kind regards,
    Steve
    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
  8. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 29 Apr 2011 Link to this post

    Thanks, that did the trick
Back to Top
DevCraft banner