【问题标题】:Reportviewer control loading indicator in ASP.NETASP.NET 中的 Reportviewer 控件加载指示器
【发布时间】:2012-06-02 19:49:27
【问题描述】:

我只是用新主题为我的网站换肤,是否可以更改 ReportViewer 控件的加载图像(绿色)?

我尝试了一些建议的解决方案,但它不起作用,有人可以指导我吗?

【问题讨论】:

  • 我相信这些都嵌入在reportviewer dll中。可悲的是,我不知道任何简单的方法来改变它。

标签: javascript asp.net css reporting-services reportviewer


【解决方案1】:

你总是可以用 CSS 修改它。

如果您调查从 ReportViewer 控件呈现的 HTML,应该有一个名为 [ID_of_control]_AsyncWait_Wait<div>

在我的,我有 css;

<style>
    /* this will remove the spinner */
    div#ReportViewer1_AsyncWait_Wait img{ display: none; } 
    /* this allows you to modify the td that contains the spinner */
    div#ReportViewer1_AsyncWait_Wait table tbody tr td:first-child{ background: red; width: 100px; height: 100px; } 
</style>

您需要做的就是在div#ReportViewer1_AsyncWait_Wait table tbody tr td:first-child 上设置background-image,以便拥有自己的自定义图像。

【讨论】:

    【解决方案2】:

    以下解决方案使用 jQuery 和 CSS 实现了替换加载图像。环境为 Visual Studio 2013、ReportViewer 10.0、.NET 4.0。

    该技术使用 window.setInterval 替换加载图像并保持它被替换。在某些情况下,例如选择级联参数,ReportViewer 会替换其大部分 DOM 内容,包括加载图像。因此,使用 CSS 背景图像或使用 jQuery 一次性替换加载图像的简单解决方案不起作用。

    给定一个添加到 .ASCX 用户控件的 ReportViewer 控件:

    <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
    
    <%-- replace stock SSRS wait control ("green spinner") with our own; execute every 200 milliseconds --%>
    <script type="text/javascript">
    $(document).ready(function () {
        OurApp.timeoutID = window.setInterval(OurApp.reportViewerWaitControlSubstitute, 200);
    });
    </script>
    
    <rsweb:ReportViewer ID="rvc0" runat="server" ... CssClass="ReportViewerControl" ... >
    </rsweb:ReportViewer>
    

    JavaScript:

    var OurApp= OurApp|| {};
    
    OurApp.reportViewerWaitControlSubstitute = function () {
        var control = $('.ReportViewerControl div[id$="_AsyncWait_Wait"] img');
        var source = control.attr("src");
        var path = "/media/images/atom.gif";
        var style = "height:48px;width:48px;border-radius:10px;margin-right:10px";
        //don't replace if already our image, or it will not animate
        if (source && (source != path)) {
            control.attr("src", path);
            control.attr("style", style);
        }
    }
    

    CSS(用于圆角和更均匀的图像和文本排列):

    .ReportViewerControl div[id$='_AsyncWait_Wait'] {
        border-radius:10px;
        padding:15px 15px 0 !important}
    

    结果:

    特定的 .gif 是一个动画原子,在加载 ReportViewer 元素时看起来非常酷!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      • 2010-12-20
      • 2012-05-28
      • 2018-12-20
      • 1970-01-01
      相关资源
      最近更新 更多