Page break and subreports
I have a main report that calls subreports. When a subreport has enough data such that it will not fit into the remaining areaof the current page the renderer inserts a page break leaving alot of ugly white space.Is there any way to sop this behaviour?This seems like a very basic thing.
August 21st, 2007 2:46pm
not sure is this is the exact reason, but are u using 8.5 * 11 layout for subreport also, if yes u need to decrease it as per your req. because a ful page cannot be accomodated in a page and so ssrs inserts a page break
Priyank
Free Windows Admin Tool Kit Click here and download it now
August 21st, 2007 3:18pm
Priyank,
All of the subreports and the main report for that matter are 8.5 x 11 but what would I change them to?Let me give you an example of my problem. Lets say the first sub report takes up three inches of the first page when rendered. If the second sub report takes up less than the remaining space (5.5 inches) it prints on the same page otherwise itpage breaks and starts on a new page. Sincethe subreportscan vary in rendered length depending on data Ihave no idea what their size willbe.
Another thread stated thatsubreports operate under and assumed KeepTogether. While this may explain what is happening it does not resolve the issue.
August 21st, 2007 3:37pm
Anybody else have thoughts on this? We're running into the same problem. We have an invoice and the first subreport prints out header information. The next subreport contains all the details for the invoice. If the number of details will fit on what remains of the first page, it will print. IF not, it page breaks to the next page leaving a ton of white space below the header. There must be a way to get a page break to occur in the middle of a subreport. Microsoft, please comment if this is possible. If not, we have to develop the invoice using a different tool set.
Thanks,
Todd
Free Windows Admin Tool Kit Click here and download it now
November 13th, 2007 2:41pm
CHeck out this post. http://blogs.msdn.com/bwelcker/archive/2005/08/19/Alien-Lanes-_2800_Logical-and-Physical-Pagination-Rules_2900_.aspx
On the comment from 2/14/07 Brian says there is an explicit keeptogether on subreports. This means that if it doesnt fit on the first page, it will move to the next page and leave whitespace.
To quote the comment:
"There is an explicit KeepTogether on the subreport. Since it doesn't fully fit on the page, it is getting pushed to the second page. We are working on more explicit control over KeepTogether. As a workaround, could you merge the subreport contents into the main report?"
So there is the answer.
BobP
November 13th, 2007 2:49pm
Thanks BobP! Sounds like there isn't a solution then unless we can merge this into the body of the main report. I'm not sure if this is possible in our case.
Free Windows Admin Tool Kit Click here and download it now
November 13th, 2007 3:08pm
I had this problem as well and it came about by upgrading to SP2. SP1 works fine. I ended up pulling the subreports out and putting them into the main report.
Mike
November 13th, 2007 7:19pm
All,This is clearly a bug and MSFT has documented this in the KB artilce.Check this posthttp://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2374376&SiteID=1 HTP.
Free Windows Admin Tool Kit Click here and download it now
November 13th, 2007 7:40pm
It is indeed a bug. In my case I found two solutions. The firstmay workif you are using the reportviewer in local mode. In our case all our reports are hosted in a .Net application and rendered through the report viewer in local mode. This allowed us to dynamically take a report with subreports and transform it into one big report. This involves renaming datasets, report items and vertical offsets. While it sounds complex it turned out to be quite simple.
The second is to use the reportviewer bya company called Data Dynamics. It is RDL compliant and as an added bonus exports to Word.
November 14th, 2007 8:23am
Thanks Kcon. I was happy to see that there is alternative atleast in the local mode. I wasn't sure how you are stitching those sub reports. Would be great if you can outline the steps in little detail.
Free Windows Admin Tool Kit Click here and download it now
November 14th, 2007 2:26pm
Surkot,
The exact routine to stitch together the subreporets will probably be dictated by your unique scenario. In our case the main report only uses the header and footer sections of the RDL while the subreports only use the body.If for some reason the user defined info in the unusedsections we throw it out at run time.
Basically weloop throughthesubreport collection and sendthe following to a function; RDL stream, loop counter, anf vertical offset (this is zero on the firstiteration). The function passes back to use the modified RDL and the new vertical offset.
The function does a few things.
1. It uses an xmttext reader to cycle through the RDL nodes.It look fornodes atdepth level 3 with the body sectionthat are report items (table, martix, text box etc.). These are top level items and the only ones that need to have there Top property changed since any nested controls have top properties are relative to the parent. The one thing to note is that report items with a top set to zero do not have a top property present so this needs to be added. Basically the top property is the old value plus the offset.
2. Retreive the body height value from thesubreport RDL stream andreturn this plus the current offset back as the new offset.
3. Prefix all report items with some value based on the loop counter.Example,"mytable" becomes subreport1_mytable".
4. Change the dataset name(s) to be unique based on counter.
November 15th, 2007 11:45am
Thanks Kcon for the detailed info. We will try it out at our end.
Free Windows Admin Tool Kit Click here and download it now
November 16th, 2007 9:56am
I would also like to try Kcon's solution.
It is possible to post some code? Has anyone else got this working?
You mention looping through the subreport collection - how can the sub-report collection be accessed?
Are you talking here about the SubReportEventHandler?
Then you mention passing the RDL stream to a function - how can this be achieved?
The Local Report has a LoadSubreportDefinition functionwhich takes a stream, but there is no property to access this.
Or do you maintain a reference to this stream -i.e. letthe sub report event handler do its processing, and then at the end retrieve this stream from the reference and then send it to your function?
I would really like to implement this solution
June 23rd, 2008 8:59pm
When I said subreport collection I did not mean via the report viewer. In our scenario we have a main report with many sub reports. We load the main report RDL into memort and loop through it to create a collection (if you will of the subreports). We then take each subreport and in a loop rename all the report objects based on the loop count. For instance if a subreport was referring to a dataset called MyData" and it was the third subreport processed we would rename every MyData element in that subreport RDL to Loop_3_MyData. We would also set the top proprietes using the calculated offset. In the end we have one big string that is composite of all the subreports. We then convert that to a memory stream and use the LoadReportDefinition method of the report viewer to load the memory stream. Next we load every dataset (renamed of course) that each sub reportwill need.Remember, this isnow one report so you do not use the LoadSubReportDefinition or SubReportEventHandler. The code (not including the stitching together of the RDL XML data) issomething like this;
Dim xr As New XmlTextWriter(sw) xr.Formatting = Formatting.Indented xd.WriteTo(xr)
If Not IsNothing(xr) Then xr.Close() End If
layout = sb.ToString ' this is the RDLs stitched together
buff = cnv.GetBytes(layout) sr.Write(buff, 0, buff.Length) sr.Seek(0, SeekOrigin.Begin) rv.LocalReport.LoadReportDefinition(sr)
set_main_params()
Dim dtx As New DataTable Dim col1 As New DataColumn col1.ColumnName = "x" dtx.Columns.Add(col1) Dim drx As DataRow = dtx.NewRow drx.Item(0) = 1 dtx.Rows.Add(drx)
Dim dsname As String = "Dataset1"
Dim rs As New Microsoft.Reporting.WinForms.ReportDataSource(dsname, dtx) rv.LocalReport.DataSources.Add(rs) dID = 1 For Each kv As KeyValuePair(Of String, String) In secDatasets dID += 1 If kv.Value & "" <> "" Then For Each dt As DataTable In dsmaster.Tables ' holds all theretrieved datasets for the subreports If dt.TableName.ToLower = projectpath.ToLower & "_" & kv.Key.ToLower Then Dim dIDStr As String = "" If dID < 10 Then dIDStr = "00" & dID ElseIf dID < 100 Then dIDStr = "0" & dID Else dIDStr = dID.ToString End If Dim rs1 As New Microsoft.Reporting.WinForms.ReportDataSource("Dataset" & dIDStr, dt) rv.LocalReport.DataSources.Add(rs1) End If Next End If
Next
Try Me.rv.RefreshReport() Catch MsgBox(Err.Description) End Try
Free Windows Admin Tool Kit Click here and download it now
June 25th, 2008 10:28am
Guys,I was having the same issue, but finally found a cheap work around which works for me ;)In my Main Report sub report A Dummy Thin Rectangle set border (.25) + property page break after rectangle sub report B Dummy Thin Rectangle set border (.25) + property page break after rectangle sub report C Dummy Thin Rectangle set border (.25) + property page break after rectangle sub report D Dummy Thin Rectangle set border (.25) + property page break after rectangleThanksJohn
March 2nd, 2010 9:52am
I was able to get around this issue in SSRS 2008 be setting all of the KeepWithGroup tags inside of the TablixMember tags to "Nothing" in the rdl. That seemed to make my report print continuously, although it may have other unintended consequences.
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2010 3:47pm
I am not sure about the earlier version of SSRS, but I faced this same issue in SSRS 2008.
The solution is to change the Subreport property in Code.
1. Go to the solution explorer, right click on your report and click on "View Code".
2. Search for your Subreport.
3. Inside subreport tag you'll find "<KeepTogather>", which would be set to "true", change it to "false"
This property is not avaiable from designer and has to be changed from the actual report xml code.
May 16th, 2012 10:17am