gpt4 book ai didi

iframe - 报告加载时的 ReportViewerForMvc 事件

转载 作者:行者123 更新时间:2023-12-01 22:43:24 25 4
gpt4 key购买 nike

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

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

目前,我有一个所有报告的共享 View ,我希望向其中添加一些 JavaScript:

@using ReportViewerForMvc;

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

最佳答案

iframe onload 无法在此处停止旋转器。您需要 cookies 和客户端脚本来完成此操作。服务器代码将在 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>

关于iframe - 报告加载时的 ReportViewerForMvc 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44292096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com