views:

1647

answers:

3

Hi,

I'm using MSSQL 2005 Reporting Services and in this case I need to display some reports on an ASP.NET page using the ReportViewer control (I guess thats the only way, right?).

The problem is that I can't get the property SizeToReportContent to work. When displaying the report, I get a vertical scrollbar because the report is too large. It looks like an iframe window. Searching on google it seems to be a bug. It can be fixed by setting AsyncRendering to false but I don't want that. I need another solution.

I was wondering if it's possible to set the height on the report element using JavaScript after the report has been loaded?

Or do you know of another solution? This is really annoying.

Thanks in advance.

+1  A: 

I can't fully recall which way to go - but you either need to change the ReportViewer from Asynch to Synch rendering. I dealt with this about 3 years ago and think that is what we did.

StrateSQL
But I would really like to avoid that.
Tommy Jakobsen
The trouble is that when the report is being rendered it doesn't know how large it will be. Until the rendering is complete it doesn't know that. There may be a java solution that's come out since I last had to deal with this, though.
StrateSQL
Thanks, this worked for me.Like Tommy said - it's not ideal, but if you don't know how big the report is there's little you can do. Another option would be to dynamically set the viewer height by getting the client's browser window height using Javascript.
Stefan Mohr
A: 

This is supposedly solved with the ReportViewer bundled with Visual Studio 2010 beta 2:

http://blogs.msdn.com/brianhartman/archive/2010/01/21/asyncrendering-and-all-the-baggage-that-comes-with-it.aspx

That said, I tried swapping out to the new version and just encountered a huge number of new, exciting, and different cross-browser issues. It may work well enough for what you're trying to do though.

Stefan Mohr
+1  A: 

You can set the height using javascript and keep Async=true. I use this now on the 2008 version. Here is the code I use:

<script language="JavaScript" type="text/JavaScript">
    function doResize() {
        var viewer = document.getElementById("<%=ReportViewer1.ClientID %>");
        var htmlheight = document.documentElement.clientHeight; 
        viewer.style.height = (htmlheight - 150) + "px";
    }

    window.onresize=function resize()
    { 
        doResize();
    }
</script>

<rsweb:ReportViewer ID="ReportViewer1" BackColor="#f2f2f2" 
    InternalBorderStyle="Solid" InternalBorderColor="Gray" ProcessingMode="Remote" 
    AsyncRendering="true" Width="100%" runat="server" 
    meta:resourcekey="ReportViewer1Resource1">
    <ServerReport  />        
</rsweb:ReportViewer>

<script language="JavaScript" type="text/JavaScript">
    doResize();
</script>

This doesn't work on VS2010 ReportViewer, however. I'm trying to figure out a solution for that.

ericvg