2015-08-17 42 views
1

我遵循本文檔中的說明link。 xtrareport顯示框的工具欄,但它不顯示任何數據。我究竟做錯了什麼?XtraReport未顯示任何數據

在我HomeController.cs

public ActionResult Index() 
     { 
      ViewBag.Message = "Welcome to DevExpress Extensions for ASP.NET MVC!"; 
      ViewData["Report"] = new DXApplication.Reports.XtraReport1(); 

      return View(); 
     } 

     public ActionResult DocumentViewerPartial() 
     { 
     ViewData["Report"] = new DXApplication.Reports.XtraReport1(); 
     return PartialView("DocumentViewerPartial"); 
     } 



     public ActionResult ExportDocumentViewer() 
     { 
      return DevExpress.Web.Mvc.DocumentViewerExtension.ExportTo(new DXApplication.Reports.XtraReport1()); 
     } 

DocumentViewerPartial.cs

**@Html.DevExpress().DocumentViewer(settings => 
{ 
    settings.Name = "DocumentViewer"; 
    settings.Report = (DXApplication.Reports.XtraReport1)ViewData["Reports"]; 

    settings.CallbackRouteValues = new { Controller = "Home", Action = "DocumentViewerPartial" }; 
    settings.ExportRouteValues = new { Controller = "Home", Action = "ExportDocumentViewer" }; 
}).GetHtml()** 

而且Index.cshtml由DocumentViewerPartial.cs 0123改變

{ 
    ViewBag.Title = "Home Page"; 

} 
@ViewBag.Message 

@Html.Action("DocumentViewerPartial") 

回答

0

嘗試ViewData["Reports"]ViewData["Report"]

0

在XtraReport1中你怎麼寫?如果您提供代碼XtraReport1或向我們提供一個簡單的案例演示,那將是非常好的。我看到你的控制器,如果你寫這個,它會得到數據第三: ViewData [「Report」] = new DXApplication.Reports.XtraReport1();

  1. 在指數()的第一個
  2. 在DocumentViewerPartial()
  3. 在ExportDocumentViewer()第三個第二

準備好你只需要獲取數據1,你可以這樣寫:

public ActionResult Index() 
    { 
     ViewBag.Message = "Welcome to DevExpress Extensions for ASP.NET MVC!"; 
     return View(); 
    } 

    public ActionResult DocumentViewerPartial() 
    { 
    Session["Report"] = new DXApplication.Reports.XtraReport1(); 
    return PartialView("DocumentViewerPartial"); 
    } 

    public ActionResult ExportDocumentViewer() 
    { 
     return DevExpress.Web.Mvc.DocumentViewerExtension.ExportTo(Session["Report"] as XtraReport1()); 
    } 

並在DocumentViewerPartial.cs中編輯:

@Html.DevExpress().DocumentViewer(settings =>{ 
settings.Name = "DocumentViewer"; 
settings.Report = (DXApplication.Reports.XtraReport1)Session["Reports"]; 

settings.CallbackRouteValues = new { Controller = "Home", Action = "DocumentViewerPartial" }; 
settings.ExportRouteValues = new { Controller = "Home", Action = "ExportDocumentViewer" };}).GetHtml() 

然後在文件最後Index.cshtml你撥打:

@Html.Partial("ExportDocumentViewer") 
@Html.Partial("DocumentViewerPartial") 

請進行相應的修改,讓我知道你的結果。