【问题标题】:ReportViewerForMvc event on report load报告加载时的 ReportViewerForMvc 事件
【发布时间】:2017-11-01 16:34:57
【问题描述】:

我正在使用 ReportViewerForMvc 在 iframe 中加载报告。目前,我有一个微调器,以便用户知道报告正在加载。但是,当 iframe 放置在页面上时,微调器会停止旋转……而不是在报表内容完成呈现时。我发现有人使用 isLoading 和 $find 但我很确定这只是用于 asp 并且我需要在 .Net 中

让微调器继续旋转直到报表加载到 iframe 中的最简单方法是什么?

目前,我对所有希望添加一些 javascript 的报告都有一个共享视图:

@using ReportViewerForMvc;

<div id="reportViewer">@Html.ReportViewer(Model.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)</div>

【问题讨论】:

标签: iframe reporting-services webforms reportviewer client-side


【解决方案1】:

iframe onload 无法在此处停止微调器。您需要 cookie 和客户端脚本来完成此操作。 服务器代码将在 cookie 中设置值。一旦呈现报告,将在客户端(cshtml)读取该值,并且可以停止微调器。

阅读这篇文章。在这里你可以用微调器替换拦截器。

http://gruffcode.com/2010/10/28/detecting-the-file-download-dialog-in-the-browser/

   //This should be called on the event when you are loading the report 
   //In your case you will route the url to controller or invoke the link 
   //for the report 

 $(document).ready(function () {
 $('#create_pdf_form').submit(function () {
  blockUIForDownload();
});

});

//This is where you will place the spinner
function blockUIForDownload() {
 var token = new Date().getTime(); 
  //use the current timestamp as the token value
  $('#download_token_value_id').val(token);
  $.blockUI();
  fileDownloadCheckTimer = window.setInterval(function () {
   var cookieValue = $.cookie('fileDownloadToken');
   if (cookieValue == token)
     finishDownload();
   }, 1000);
}
 //This will read the token generated from the server side controller or 
 //aspx.cs or ashx handler
 function finishDownload() {
    window.clearInterval(fileDownloadCheckTimer);
    // $.removeCookie('fileDownloadToken'); //clears this cookie value
    //$.cookie('fileDownloadToken', null);
    //$.removeCookie("fileDownloadToken");
    setCookie("fileDownloadToken", '2')
    $.unblockUI();
}


//On the server side set the token , it could be controller or ashx handler
  var response = HttpContext.Current.Response;
  response.Clear();
   response.AppendCookie(new HttpCookie("fileDownloadToken", 
 downloadTokenValue); //downloadTokenValue will have been provided in the 
 form submit via the hidden input field

  response.Flush();

  //Lastly don't forget to add these source js files.
  <script src="~/Scripts/jquery-1.5.1.js"></script>
  <script src="~/Scripts/jquery.blockUI.js"></script>
  <script src="~/Scripts/jquery.cookie.js"></script>

【讨论】:

  • 请在此处包含链接中的相关部分。
  • 我已经添加了 sn-ps,这将有助于了解在哪里以及做什么。如果实施此操作有问题,请告诉我。
猜你喜欢
  • 1970-01-01
  • 2018-09-18
  • 2012-10-16
  • 1970-01-01
  • 2017-01-01
  • 1970-01-01
  • 2020-03-18
  • 1970-01-01
  • 2012-04-09
相关资源
最近更新 更多