首页 > Web开发 > 详细

DevExpress MVC Report Demos 解析

时间:2020-04-08 01:27:16      阅读:114      评论:0      收藏:0      [点我收藏+]

找到控制器:

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));

}

}

}

?

这里比较重要,我们需要找出传值的model到底有些什么?

因此先进入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)

};

}

?

好了,找到有Report对象的赋值了,它从哪里来?(ReportStorageHelper.LoadReport)

?

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设计的文件了。

技术分享图片

?

找到无参数Action的视图:

@if(Model.IsHTML5Viewer) {

@Html.DevExpress().WebDocumentViewer(settings => {

settings.Name = "webDocumentViewer";

}).Bind(Model.ReportID).GetHtml()

}

else if(Model.IsMobileViewer) {

@Html.Partial("MobileEmulator", Model.EmulatorModel)

}

调试,看它的Bind对象:

技术分享图片

?

找回Bind对象Action:
public ActionResult EmployeePerformanceReviewPartial(string reportID) {

return PartialView("EmployeePerformanceReviewPartial", ReportDemoHelper.CreateModel(reportID, Session, Request));

}

?

找到PartialView:

@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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!