Kontrola ReportViewer-problem z wysokością

In my asp.net aplikacja, próbuję otworzyć konkretny raport. Mam zestaw sterujący ReportViewer o szerokości 100% i wysokości 100%. Teraz spodziewam się, że to oznacza, że raport zajmie całą stronę. Cóż, ku mojemu zdziwieniu, nie ma. W IE7 podczas gdy zajmuje całą szerokość strony, zajmuje tylko niewielką część wysokości. W Firefoksie zarówno szerokość, jak i wysokość są pomieszane. Mam przeglądarkę otwierającą nową stronę, która zajmuje prawie cały ekran. Jakieś pomysły?

Dzięki!

Author: Dan Appleyard, 0000-00-00

11 answers

Podaj statyczną wysokość, która wystarczy dla całej wysokości raportu. Z tego co wiem 100% nie zadziała, ponieważ kontrola ReportViewer jest zasadniczo owinięta jednym dużym znacznikiem div.

 7
Author: mccrager,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-02 22:43:40

This is the way I fixed, take a look

<div style="Width:auto;"> 
<form id="form1" runat="server" style="width:100%; height:100%;">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <rsweb:ReportViewer ID="rptViewer" runat="server" Width="100%" Height="100%" AsyncRendering="False" SizeToReportContent="True">
    </rsweb:ReportViewer>
</form></div>

Rzeczą wykonującą magię jest Asyncrending= "False" SizeToReportContent= "True" Reszta to podstawowy HTML. Raport zostanie wyświetlony zgodnie z jego projektem.

Może jest jakiś dodatkowy kod, ale sprawdź, czy działa.

Hope it helps

 62
Author: Sanchitos,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-07-09 03:26:31

Tak to naprawiłem, ustawiając dynamicznie wysokość za pomocą javascript, działa zarówno z IE jak i Firefoksem. działa również z raportami większymi niż maksymalny rozmiar okna.

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="100%" ShowBackButton="True" ProcessingMode="Remote" />

<script language="javascript" type="text/javascript">
    ResizeReport();

    function ResizeReport() {
        var viewer = document.getElementById("<%= ReportViewer1.ClientID %>");
        var htmlheight = document.documentElement.clientHeight;
        viewer.style.height = (htmlheight - 30) + "px";
    }

    window.onresize = function resize() { ResizeReport(); }
</script>
 11
Author: Ghulam Murtaza,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-01-21 14:24:20

Miałem ten sam problem z ReportViewer 11.0 i co zrobił dla mnie trick było ustawić

Height="100%" 
SizeToReportContent="true"

while keeping 

AsyncRendering="true"

Eg

<rsweb:ReportViewer ID="reportControl" runat="server" Width="750" Height="100%" AsyncRendering="true" SizeToReportContent="true">

To faktycznie wygenerowało tabelę z height= "100%" dla kontrolki.

 9
Author: Ovidiu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-13 16:06:02

Jest to problem ze standardem XHTML 1.1. Zmień doctype strony na transitional, aby uzyskać 100% wysokości pracy:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

Lub jeśli nadal walczysz, usuń go całkowicie.

 3
Author: Mark Cooper,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-09-27 15:36:25

Wiem, że to stare pytanie, ale ostatnio wciąż się z nim zmagałem. Wygląda na to, że poniższe działa dobrze we wszystkich nowoczesnych przeglądarkach (tylko testowane IE8/9, Firefox i Chrome). Kickerami dla mnie były doctype i html element height.

<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        html, body, form { width: 100%; height: 100%; margin: 0; padding: 0 }
    </style>
</head>
<body>
  <form runat="server">
    <asp:scriptmanager runat="server" />
    <rsweb:ReportViewer ID="ReportViewerControl" Width="100%" Height="100%" runat="server" />
  </form>
</body>
</html>
 3
Author: jamisonLikeCode,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-18 18:54:12

Dan, oto co zrobiliśmy z odrobiną magii jQuery.

Wszystkie raporty używały tego samego raportu.Master jako strona wzorcowa:

<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Report.master.vb" Inherits=".Report" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
     <style type="text/css">
        html, body
        {
            margin: 0;
            padding: 0;            
            border: none;
            background-color: #FFFFFF;     
            overflow: hidden;       
        }
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            setWindowSize();
        });

        $(window).resize(function () {
            setWindowSize();
        });

        function setWindowSize() {
            // http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
            var myWidth = 0, myHeight = 0;
            if (typeof (window.innerWidth) == 'number') {
                //Non-IE
                myWidth = window.innerWidth;
                myHeight = window.innerHeight;
            } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
                //IE 6+ in 'standards compliant mode'
                myWidth = document.documentElement.clientWidth;
                myHeight = document.documentElement.clientHeight;
            } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                //IE 4 compatible
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
            }

            var r = $('div[id*="_report_"]:first');
            r.width(myWidth);
            r.height(myHeight - 32);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">    
        <asp:ScriptManager ID="rptScriptManager1" runat="server" />
        <asp:ContentPlaceHolder ID="report" runat="server"/>                
    </form>
</body>
</html>

Następnie każda strona raportu zawierała ReportViewer i jego właściwości.

<%@ Page Title="This Cool Report" MasterPageFile="~/masterpages/Report.Master" Language="vb" AutoEventWireup="false" CodeBehind="viewmycoolreport.aspx.vb" Inherits=".viewmycoolreport" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<asp:Content ID="reportContent" ContentPlaceHolderID="report" runat="server">    
    <rsweb:ReportViewer ID="rptCoolReport" runat="server" Width="100%" ProcessingMode="Remote" SizeToReportContent="True" />
</asp:Content>

Teraz, gdy raport się ładuje, kontrolka ReportViewer kończy się rozmiarem okna zawartości, zarówno przy gotowym, jak i przy zmianie rozmiaru okna. Selektor jQuery chwyta pierwszy div z identyfikatorem zawierającym " _report_ "(od ReportViewer sterowanie renderuje z identyfikatorem klienta ctl_report_). Wysokość musi być mniejsza niż 32 piksele z powodu nagłówka w kontrolce ReportViewer (do stronicowania, eksportu itp.).

 3
Author: Steve Wright,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-19 18:05:43

Poniższe opcje naprawią problem z ładowaniem raportu SSRS w ASP.NET strona.

I istnieje fantastyczna właściwość o nazwie ZoomMode= "PageWidth" , która naprawi twój raport na pełną stronę. możesz również użyć ZoomMode="FullPage" lub ZoomMode="Percent". Wszystkie te właściwości naprawią problem z ładowaniem strony w ASP.NET strona.

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="100%" Width="100%" ZoomMode="Percent"></rsweb:ReportViewer>
 3
Author: ABM Abdul Muttalib,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-23 09:53:43

Ostatnio usiadłem i walczyłem z kontrolą ReportViewer, Aby rozszerzyć zawartość raportu, jednocześnie pozwalając .AsyncRendering = true. Oto co zrobiłem, który wymaga jQuery, i został przetestowany tylko z Report Viewer 2008 (9.0.0.0).

<script type="text/javascript">

    $(function() {

        $('#<%= uxReportViewer.ClientID %> > iframe:eq(0)').bind('load', function() {
            ReportViewerResize(this);
        });

    });

    function ReportViewerResize(frame) {
        var container = $('#<%= uxReportViewer.ClientID %>');
        try {
            var reportFrame = $(frame).contents().find('html')[0].document.frames["report"].document;
            var reportHeight = $('div#oReportDiv > table > tbody > tr > td#oReportCell', reportFrame).height();
            $(container).css({ height: '' + (reportHeight + 10) + 'px' });
        } catch (e) { }
    }

</script>
 2
Author: Cᴏʀʏ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-02-28 04:38:37

Ten kod jest nieco dłuższy, ale działa we wszystkich przeglądarkach, które testowałem z asynchronicznym renderowaniem i bez niego. Najlepsza część jest w trybie nie-asynchronicznym, rozszerza się do rozmiaru zawartości raportu. W trybie asynchronicznym rozszerza się do rozmiaru strony (minus przesunięcie od góry). Powinienem zauważyć, że jest to specyficzne dla wersji reportviewer VS2010.

<script type="text/javascript">
function ResizeReport(reportId){
        var rep = document.getElementById(reportId);
        var j = 0;

        for (var i = 0; i < rep.childNodes.length; i++) {
            var child = rep.childNodes[i];
            if (child.nodeName == "DIV") {
                j++;
                if (j == 2) {
                    child.firstChild.style.overflow = "";
                    while (child.nodeName == "DIV") {
                        child = child.firstChild;
                    }
                    child.style.width = "1px";
                    rep.style.width = (child.clientWidth) + "px";
                    rep.style.height = "";
                    return;
                }
            }
        }

        if (rep.style.height != '400px') // default value //
            return;
        ResizeReportHeight(reportId);
        window.onresize = function () { ResizeReportHeight(reportId); }
    }

    // Used to resize an async-report. Hand edit as needed.
    function ResizeReportHeight(reportId, offsetFromBot) {
        var rep = document.getElementById(reportId);
        var iFrame = rep.getElementsByTagName('iframe')[0];
        var htmlHeight = document.documentElement.clientHeight;
        var offTop = 0;
        var obj = iFrame;
        while (obj) {
            offTop += obj.offsetTop;
            obj = obj.offsetParent;
        }
        var newHeight = (htmlHeight - offTop)
        if (offsetFromBot)
            newHeight -= offsetFromBot;
        if (newHeight < 1)
            newHeight = 1;
        rep.style.height = "";
        iFrame.style.height =  newHeight + "px";
    }
</script>
<script type="text/javascript">
    window.onload = function () { ResizeReport("<%= reportviewer1.ClientID %>"); }
</script>
<rsweb:reportviewer ID="reportviewer1" runat="server" ProcessingMode="Remote" Width="100%" />
 2
Author: Theodosius,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-10-05 17:01:01

Co do tego, czego doświadczyłem, Kontrola przeglądarki raportów jest domyślnie renderowana z wysokością 400px, jeśli sizetoreportcontent jest ustawiony na false.
Jeśli chcesz mieć dynamiczną wysokość, musisz dodać klasę css do przeglądarki raportów i następujący css:

#reportViewerContainer > span
{
    display:block;
    height:100% !important;
}

.reportViewer
{
    height:100% !important;
}

"reportViewerContainer" jest nadrzędnym kontenerem przeglądarki raportów (div, body itd.). Przeglądarka renderuje jako rozpiętość o wysokości: 0, a wewnątrz znajduje się cała zawartość. Jeśli to zmienisz, wszystko powinno działać dobrze.

 0
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-20 12:15:37