【问题标题】:Can you get parameter values of reportviewer at runtime?可以在运行时获取reportviewer的参数值吗?
【发布时间】:2014-01-10 01:27:58
【问题描述】:

我有一个关于 Reporting Services 报表查看器控件的非常具体的问题。

感谢您的帮助。我在客户端使用 Javascript 有点新手,但我必须在我的项目中使用它。

要求

我需要在运行时检索嵌入在 Web 部件中的报表查看器控件上的单个参数的当前值。我需要在客户端使用 Javascript 访问该值。

这甚至可以做到吗?报告查看器似乎没有被渲染。

报告查看器的 HTML 代码

<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnUnload="UpdatePanel_Unload">
    <ContentTemplate>
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" 
            Font-Names="Verdana" Font-Size="8pt" Height="383px" 
            InteractiveDeviceInfos="(Collection)" ProcessingMode="Remote" 
            WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="757px" 
            SizeToReportContent="True">
        </rsweb:ReportViewer>
    </ContentTemplate>
</asp:UpdatePanel>

【问题讨论】:

  • 要做到这一点,您需要在您的 asp.net 应用程序中使用脚本管理器,因为参数可以更改并且不会在您的设置中回发到您的应用程序。您将需要使用 JavaScript 来迭代 ReportViewer1 的子元素并找到参数控件并提取值。
  • 谢谢伊布。我在那里有一个脚本管理器。更新面板和相关的报表查看器嵌入在 Web 部件中。我可以从 webpart 开始,然后在报表查看器和子元素中工作吗?
  • 如果您在运行应用程序时按 f12,webpart 是否会显示在 dom 中?
  • #WebPartctl00_m_g_9d6a6c3c_11d0_4e03_bbd2_b907172c437d#ctl00_m_g_9d6a6c3c_11d0_4e03_bbd2_b907172c437d_ctl01_UpdatePanel1#ctl00_m_g_9d6a6c3c_11d0_4e03_bbd2_b907172c437d_ctl01_ReportViewer1 跨度>
  • asp.net 为您提供一个客户端 ID 值,该值可解析为您所看到的 guid 类型 ID...您必须使用客户端 ID 和 javascript 函数来查找 $("#

标签: javascript reporting-services reportviewer web-parts


【解决方案1】:

更新-下面的工作代码

关键是创建一个自定义数据属性,如此链接 (http://html5doctor.com/html5-custom-data-attributes/) 中所示的@Fil,并从后面的代码传递,然后访问 $.cache。并将reportviewer 的clientID 传递给javascript 函数以获取webpart 子控件的当前实例。

<input type="hidden" id="<%= ASP_SSRS.ClientID %>_myDataState" 
onchange="compareUnitValues(this.id, this.parentNode.id, '<%= ReportViewer1.ClientID %>',  '<%= ASP_SSRS.ClientID %>', '<%= btnSendHiddenField.ClientID %>');" />

<script type ="text/javascript">
function compareUnitValues(elemt, parent, reportviewerID, value1, value2) {
  var myDataUnit = $("#" + elemt),
     parentObject = $("#" + parent),
     reportviewerObject = $("#" + reportviewerID),
     ssrs    = $("#" + value1),
     btnSend = $("#" + value2);

  var myDataUnitValue = myDataUnit.val();
  var myDataUnitJSON = jQuery.parseJSON(myDataUnitValue);
  var currentmyDataUnit = myDataUnitJSON.currentUnit.objectId;
  var sessioncurrentObjectId = document.getElementById('<%= hiddenCurrentObjectId.ClientID %>').value;
  ssrs.val(myDataUnitValue);
  var currentReportViewerParam = $("#" + reportviewerID).attr("data-report-param");

  if (currentmyDataUnit != currentReportViewerParam) {
  btnSend.trigger("click");
  }    

}

从后面的代码创建自定义数据属性
ReportViewer1.Attributes.Add("data-report-param", parsedObjectId)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-16
    • 1970-01-01
    • 2021-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多