2017-05-31 118 views
4

我使用ReportViewerForMvc在iframe中加載報告。目前,我有一個微調框,以便用戶知道報告正在加載。但是,當iframe放置在頁面上時,微調控制器停止旋轉...而不是在報表內容完成呈現時。我發現人們使用isLoading與$ find,但我很確定這只是爲asp,我需要我在.netReportViewerForMvc事件報告加載

什麼是最簡單的方法讓微調控制器繼續旋轉,直到報告加載iframe?

目前,我有,我希望一些JavaScript添加到所有報表的共享視圖:

@using ReportViewerForMvc; 

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

https://github.com/armanio123/ReportViewerForMvc/issues/3請在此 –

回答

0

的iframe的onload不起作用停止微調器here.You需要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> 
+0

請包括從這裏的鏈接相關的部分看看。 – Sunil

+0

我已添加片段,以幫助瞭解在哪裏以及要做什麼。讓我知道是否存在實施此問題的問題。 – rmehra76