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

Report Alignment in Web Viewer

1 Answer 155 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe Sugden
Top achievements
Rank 1
Joe Sugden asked on 22 Nov 2011, 11:06 PM
Hello,

We have a Web Report Viewer that spans the width of the whole page.
However the report that is displayed in it, is align left by default, and we would like it to be centered.
How do we achieve this behavior?

See screenshot

Thanks!

1 Answer, 1 is accepted

Sort by
0
Accepted
Squall
Top achievements
Rank 1
answered on 23 Nov 2011, 03:22 PM
Hi Joe,
You can use JavaScript to change the report's alignment:

<telerik:ReportViewer ID="ReportViewer1"runat="server"  style="border:1px solid #ccc;"width="99%"height="99%"/>
            <script type="text/javascript">
                ReportViewer.prototype.OnReportLoadedOld = ReportViewer.OnReportLoaded;
                ReportViewer.prototype.OnReportLoaded = function() {
                    this.OnReportLoadedOld();
  
                    varreportFrame = document.getElementById(this.reportFrameID);
                    varreportDocument = reportFrame.contentWindow.document;
                    varbody = reportDocument.getElementsByTagName("body")[0];
                    if ($telerik.isIE7 || $telerik.isIE8) {
                        var outerdiv = body.childNodes[0];
                    } else {
                        var outerdiv = body.childNodes[1];
                    }
 
                    outerdiv.style.marginLeft = "auto";
                    outerdiv.style.marginRight = "auto";
                }
</script>

Tags
General Discussions
Asked by
Joe Sugden
Top achievements
Rank 1
Answers by
Squall
Top achievements
Rank 1
Share this question
or