2016-06-27 1 views
-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>&nbsp; 

이 자바 스크립트) (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); 
     } 

답변

1

메시지와 함께 div를 만들려면이 코드를 사용하십시오.

<div id="effect" class="ui-widget-content ui-corner-all">  
<p>Loading Files...</p> 
</div> 

javascript 함수 안에 팝업을 표시하려면 show 함수를 사용하십시오.

function getAllChecked() {$("#effect").show(selectedEffect, options, 500, callback);} 

그리고 아약스의 성공은 팝업을 숨 깁니다.

success: function (data) { 
      if (data.success) {$("#effect:visible").removeAttr("style").fadeOut();} 

희망이 도움이됩니다.

+0

제안 : 팝업을 사용하는 대신, 쉽게 표시하고 숨길 수있는로드하는 gif 이미지를 사용하지 않는 이유는 무엇입니까? 간단한 jQuery를 사용하여 보고서 생성 버튼 클릭 및 아약스 성공을 숨길 때 이미지를 표시 할 수 있습니다. –

+0

고맙습니다, 잘 작동합니다 :) – alenan2013

관련 문제