namespace DevExpress.Web.Demos {
public partial class InteractionController : ReportDemoController {
public ActionResult EmployeePerformanceReview() {
var model = ReportDemoHelper.CreateModel("EmployeePerformanceReview", Session, Request);
return DemoView("EmployeePerformanceReview", "EmployeePerformanceReview", model);
}
?
public ActionResult EmployeePerformanceReviewPartial(string reportID) {
return PartialView("EmployeePerformanceReviewPartial", ReportDemoHelper.CreateModel(reportID, Session, Request));
}
}
}
?
因此先进入ReportDemoHelper.CreateModel方法:
public static ReportsDemoModel CreateModel(string reportID, HttpSessionStateBase session, HttpRequestBase request) {
return new ReportsDemoModel {
ReportID = reportID,
Report = ReportStorageHelper.LoadReport(reportID, session),
CurrentViewer = request.Params[ViewerSelectorState.Key],
EmulatorModel = new MobileEmulatorModel(reportID, request)
};
}
?
?
public static XtraReport LoadReport(string reportId, HttpSessionStateBase session) {
var reportLayout = GetReportLayout(reportId, session);
if(reportLayout != null) {
using(var stream = new MemoryStream(reportLayout)) {
return XtraReport.FromStream(stream, true);
}
}
return ReportDemoHelper.GetReport(reportId);
}
以上就解释了Report Style file的来源了,理论上来讲,因该可以使用web和form设计的文件了。
?
@if(Model.IsHTML5Viewer) {
@Html.DevExpress().WebDocumentViewer(settings => {
settings.Name = "webDocumentViewer";
}).Bind(Model.ReportID).GetHtml()
}
else if(Model.IsMobileViewer) {
@Html.Partial("MobileEmulator", Model.EmulatorModel)
}
?
return PartialView("EmployeePerformanceReviewPartial", ReportDemoHelper.CreateModel(reportID, Session, Request));
}
?
@using DevExpress.Web.Demos.Code.Designer
@model ReportsDemoModel
@Html.DevExpress().DocumentViewer(settings => {
settings.Name = "DocumentViewer";
settings.Report = Model.Report;
settings.SettingsSplitter.DocumentMapCollapsed = true;
settings.CallbackRouteValues = new { Controller = "Interaction", Action = "EmployeePerformanceReviewPartial", ReportID = Model.ReportID };
settings.ExportRouteValues = new { Controller = "Interaction", Action = "DocumentViewerExportTo", ReportID = Model.ReportID };
}).GetHtml()
?
好了,到这里就是主要代码了。
但是怎么动态绑定数据还是没闹明白,跟CS还是有很大的区别啊。
DevExpress MVC Report Demos 解析
原文:https://www.cnblogs.com/honk/p/12657339.html