我已按照本文档link中的说明操作。 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
{
ViewBag.Title = "Home Page";
}
@ViewBag.Message
@Html.Action("DocumentViewerPartial")
答案 0 :(得分:0)
尝试更改DocumentViewerPartial.cs
ViewData["Reports"]
与ViewData["Report"]
答案 1 :(得分:0)
在XtraReport1中你怎么写?如果你提供你的代码XtraReport1或者为我们提供一个简单的案例演示,那就太好了。 我在你的控制器中看到,如果你写这个,它会得到第三个数据: ViewData [“Report”] = new DXApplication.Reports.XtraReport1();
准备好你只需要获取数据第一,你可以写:
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")
请执行相应的修改,并告诉我您的结果。