-2
나는 Kendo UI를 사용하는 ASP.NET MVC 응용 프로그램 (면도칼)에서 작업합니다. 고객이 버튼을 클릭하면 보고서를 보여 주어야합니다. 그러나 보고서가 너무 빠르지 않고 클라이언트 용 팝업 창에 '보고서 생성 중 - 잠시 후 결과와 함께 새 창이 나타납니다.'와 같은 메시지가 표시됩니다. 메시지가있는 팝업 창을 표시하는 방법은 무엇입니까? 그리고 코드의 어디에 있습니까? 내가 사용하는 코드를 확인하십시오. 버튼은 : 컨트롤러ASP.NET MVC 응용 프로그램에 메시지가있는 팝업 창이
function getAllChecked() {
$('#checkedMsgRep').text('');
$.ajax({
type: "POST",
url: "/PatientReport/ExportToPDF",
dataType: "json",
traditional: true,
data: { uniqueIds: checkedArray },
success: function (data) {
if (data.success) {
// $('#lnkPdfDownload').show();
//$('#lnkPdfDownload').attr('href', '/PatientReport/DownloadFile' + '?fName=' + data.fName);
$('#myFrame').attr('src', '/PatientReport/DownloadFile' + '?fName=' + data.fName);
} else {
//$('#lnkPdfDownload').hide();
}
},
error: function (jqXHR, textStatus, errorThrown) {
$('#checkedMsgRep').text('@ELSORegistry.Resources.Views.Patient.PatientStrings.CheckedError').show();
$('#hrefCheckedPatientsRep').blur();
}
});
}
I 액션이 :
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ExportToPDF(List<String> uniqueIds) {
// step 1: creation of a document-object
var document = new Document(PageSize.A4.Rotate(), 3, 3, 80, 50);
//Here is the code for export to pdf
// Add table to the document
document.Add(dataTable);
//This is important don't forget to close the document
document.Close();
byte[] byteInfo = output.ToArray();
output.Write(byteInfo, 0, byteInfo.Length);
output.Position = 0;
var fName = string.Format("File-{0}.pdf", DateTime.Now.ToString("s"));
Session[fName] = output;
return Json(new { success = true, fName }, JsonRequestBehavior.AllowGet);
}
등
을
<a class="k-button k-button-icontext k-grid-Patient" id="hrefAllCheckedPatientsRep" style="display:none;" href="#" onclick="getAllChecked();">Generate Report</a>
이 자바 스크립트) (getAllChecked 함수이고 Contoller의 다른 동작은 다음과 같습니다.
public ActionResult DownloadFile(string fName)
{
var ms = Session[fName] as MemoryStream;
if (ms == null)
return new EmptyResult();
Session[fName] = null;
return File(ms, "application/pdf", fName);
}
제안 : 팝업을 사용하는 대신, 쉽게 표시하고 숨길 수있는로드하는 gif 이미지를 사용하지 않는 이유는 무엇입니까? 간단한 jQuery를 사용하여 보고서 생성 버튼 클릭 및 아약스 성공을 숨길 때 이미지를 표시 할 수 있습니다. –
고맙습니다, 잘 작동합니다 :) – alenan2013