Reputation: 4992
I've set up a basic ReportView as follows:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<ServerReport ReportPath="/Reports/TestReport" ReportServerUrl="http://test/ReportServer" />
</rsweb:ReportViewer>
Now to adjust the height/width of the ReportView I can do something simple such as:
Height = "500px" Width = "300%"
I even found something super handy that dynamically resizes the ReportViewer based on the size of the report itself:
AsyncRendering = "false" SizeToReportContent = "true"
Doing the above will get rid of any pesky scrollbars around the ReportViewer, as it will just grow large enough to fit around the entire report. In terms of height this is fine, however I need the width of the report to always stay at a specified value (to make things look less messy).
Is this possible? Can I somehow set Width to 900px for example, and then use SizeToReportContent or the equivalent so the ReportViewer's height automatically adjusts itself to the size of the report itself without it affecting the 900px width I set.
Thanks for any help!
Upvotes: 0
Views: 1438
Reputation: 2867
There's two ways of doing this, Via C# on PageLoad:
private void Page_Load(object sender, System.EventArgs e)
{
// Set Report's Current Page & Width.
ReportViewer.CurrentPage = Report.CurrentPage;
ReportViewer.Width = new Unit(Report.Width);
// Where Report.Width is the format "12in"
// I think it accepts pixels as well. I'm not positive though.
}
Via Javascript
function AdjustWidths() {
// This grabs the first div containing "1_" since the ReportViewer Div is "1_" + ReportViewerName.
// ReportViewerName being the Identifier in the C# PageLoad. (In the example above: "ReportViewer").
var ReportViewerID = $($("div[id*=1_]")[0]).attr("id");
// Sets the width equal to the inner "_fixedTable" which is the contents.
$("#" + ReportViewerID).css("width", $("#" + ReportViewerID + "_fixedTable").css("width"));
}
The javascript method isn't full-proof (however, I have not had any problems so far). It's just a JQuery script I created to adjust the size of the viewer to be a full page. So adjust the width as desired. This will not get you what you want but with some minor changes it'll get you there.
Hope this was helpful.
Upvotes: 1