首先,您需要将StiMvcDesigner组件添加到视图页面。您还需要将StiMvcDesignerOptions对象传递给构造函数。所需的最少选项是两个操作——GetReport和DesignerEvent。需要定义PreviewReport操作,这是注册数据以预览 表所必需的。

@using Stimulsoft.Report.Mvc;...@Html.Stimulsoft().StiMvcDesigner(new StiMvcDesignerOptions(){    Actions =    {        GetReport = "GetReport",        PreviewReport = "PreviewReport",        DesignerEvent = "DesignerEvent"    }})

在上面的选项中,我们定义了几个动作,我们需要将其添加到控制器中。

GetReport操作将加载 表模板,并使用GetReportResult()静态方法将答案返回给设计器的客户端。在此方法的参数中,应传递 表对象。

public ActionResult GetReport(){    StiReport report = new StiReport();    report.Load(Server.MapPath("~/Content/Reports/TwoSimpleLists.mrt"));    return StiMvcDesigner.GetReportResult(report);}

当您在设计器中打开预览 表选项卡时,将调用PreviewReport操作。在此操作中,您可以获取 表对象并执行任何操作,例如连接到数据。要为客户准备答案,您应该使用PreviewReportResult()静态方法。在此方法的参数中,应传递 表对象。

public ActionResult PreviewReport(){    DataSet data = new DataSet("Demo");    data.ReadXml(Server.MapPath("~/Content/Data/Demo.xml"));    StiReport report = StiMvcDesigner.GetActionReportObject();    report.RegData(data);    return StiMvcDesigner.PreviewReportResult(report);}
public ActionResult DesignerEvent(){    return StiMvcDesigner.DesignerEventResult();}

在下面的屏幕截图中,您可以看到示例代码的结果。

下载示例代码

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年9月27日
下一篇 2019年9月27日

相关推荐

发表回复

登录后才能评论