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

Can not change Page break before a header in code

6 Answers 179 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jean
Top achievements
Rank 1
Jean asked on 06 Nov 2009, 08:33 PM
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 !


 

6 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 10 Nov 2009, 10:22 AM
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.
0
Jean
Top achievements
Rank 1
answered on 10 Nov 2009, 10:38 AM
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.
0
Accepted
Ivan
Telerik team
answered on 10 Nov 2009, 03:39 PM
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.
0
danparker276
Top achievements
Rank 2
answered on 27 Apr 2011, 01:25 AM
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
0
Steve
Telerik team
answered on 29 Apr 2011, 05:23 PM
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
0
danparker276
Top achievements
Rank 2
answered on 29 Apr 2011, 10:26 PM
Thanks, that did the trick
Tags
General Discussions
Asked by
Jean
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jean
Top achievements
Rank 1
Ivan
Telerik team
danparker276
Top achievements
Rank 2
Share this question
or