发布时间 : 2019-10-30 14:11:30.560|阅读 270 次
概述:此示例说明如何加载报表模板并在Flash Designer中对其进行编辑。
相关链接:
立即点击下载Stimulsoft Reports.Net最新版
此示例说明如何加载报表模板并在Flash Designer中对其进行编辑。
首先,您需要将StiMvcDesignerFx组件添加到视图页面。您还需要将StiMvcDesignerFxOptions类型的对象传递给构造函数。所需的最少选项是两个操作——GetReport和DesignerEvent,它们位于操作“Actions”选项组中。最好定义预览报表所需的PreviewReport操作。
@using Stimulsoft.Report.Mvc;
...
@Html.Stimulsoft().StiMvcDesignerFx(new StiMvcDesignerFxOptions()
{
    Actions =
    {
        GetReport = "GetReport",
        PreviewReport = "PreviewReport",
        DesignerEvent = "DesignerEvent"
    }
})在上面的选项中,我们定义了几个动作,我们需要将其添加到控制器中。
GetReport操作将加载报告模板,并使用GetReportResult()静态方法将响应返回到Flash设计器的客户端。在此方法的参数中,应传递报表对象。
public ActionResult GetReport()
{
    StiReport report = new StiReport();
    report.Load(Server.MapPath("~/Content/Reports/TwoSimpleLists.mrt"));
 
    return StiMvcDesignerFx.GetReportResult(report);
}当您在Flash设计器中打开预览报表选项卡时,将调用PreviewReport操作。在此操作中,您可以获取报表对象并执行任何操作,例如连接到数据。要为客户准备答案,您应该使用PreviewReportResult()静态方法。在此方法的参数中,应传递报表对象。
public ActionResult PreviewReport()
{
    DataSet data = new DataSet("Demo");
    data.ReadXml(Server.MapPath("~/Content/Data/Demo.xml"));
 
    StiReport report = StiMvcDesignerFx.GetReportObject();
    report.RegData(data);
    return StiMvcDesignerFx.PreviewReportResult(report);
}DesignerEvent操作处理一些Flash设计器事件(使用数据字典、获取报表模板代码和组件图像等),并使用DesignerEventResult()静态方法将答案返回给客户端。
public ActionResult DesignerEvent()
{
    return StiMvcDesignerFx.DesignerEventResult();
}在下面的屏幕截图中,您可以看到示例代码的结果。

渝ICP备12000582号-15/渝公网安备 50010702501010号