本示例说明了如何以不同的格式加载 表并在Flash查看器中显示 表。可以使用以下格式存储 表: 表模板(.mrt文件)、 表文档(.mdc文件)、编译后的 表类(.cs或.dll文件)。这些格式中的任何一种都可以加载并显示在Flash 表查看器中。
本示例说明了如何以不同的格式加载 表并在Flash查看器中显示 表。可以使用以下格式存储 表: 表模板(.mrt文件)、 表文档(.mdc文件)、编译后的 表类(.cs或.dll文件)。这些格式中的任何一种都可以加载并显示在Flash 表查看器中。
首先,您需要将StiMvcViewerFx组件添加到视图页面。另外,您需要将StiMvcViewerFxOptions对象传递给构造函数。所需的最少选项是GetReport和ViewerEvent操作。它们位于操作“Actions”选项组中。
@using Stimulsoft.Report.Mvc;...@Html.Stimulsoft().StiMvcViewerFx(new StiMvcViewerFxOptions() { Actions = { GetReport = "GetReport", ViewerEvent = "ViewerEvent" } })
要演示不同格式的加载 表,请在 页上添加链接。使用链接中的id参数 表定义。
<table> <tr> <td class="reports" valign="top"> <div style="width: 150px;"> @Html.ActionLink("Simple List", "Index", new { id = "1" }) <br />Report Snapshot <br /><br /> @Html.ActionLink("Two Simple Lists", "Index", new { id = "2" }) <br />Report Template <br /><br /> @Html.ActionLink("Master Detail", "Index", new { id = "3" }) <br />Compiled Report Class <br /><br /> @Html.ActionLink("Selecting Country", "Index", new { id = "4" }) <br />Compiled Report Class </div> </td> <td style="width: 100%;" valign="top"> @Html.Stimulsoft().StiMvcViewerFx(new StiMvcViewerFxOptions() { Actions = { GetReport = "GetReport", ViewerEvent = "ViewerEvent" } }) </td> </tr></table>
接下来,我们需要在控制器中添加定义的动作。
GetReport操作将根据URL的id参数加载 表,并使用GetReportResult()静态方法将答案返回到Flash查看器的客户端。在此方法的参数中,应传递 表对象。
public ActionResult GetReport(intnbsp;id){ // Create the report object StiReport report = new StiReport(); // Load report switch (id) { // Load report snapshot case 1: report.LoadDocument(Server.MapPath("~/Content/Reports/SimpleList.mdc")); break; // Load report template case 2: report.Load(Server.MapPath("~/Content/Reports/TwoSimpleLists.mrt")); break; // Load compiled report class case 3: report = new StiMasterDetail(); break; // Load compiled report class case 4: report = new StiParametersSelectingCountryReport(); break; // Load report snapshot default: report.LoadDocument(Server.MapPath("~/Content/Reports/SimpleList.mdc")); break; } // Load data from XML file for report template if (!report.IsDocument) { DataSet data = new DataSet("Demo"); data.ReadXml(Server.MapPath("~/Content/Data/Demo.xml")); report.RegData(data); } return StiMvcViewerFx.GetReportResult(report);}
ViewerEvent操作处理所有查看器事件,并使用ViewerEventResult()静态方法将答案返回给客户端。此操作还用于加载查看器组件的脚本。
public ActionResult ViewerEvent(){ return StiMvcViewerFx.ViewerEventResult();}
在下面的屏幕截图中,您可以看到示例代码的结果。

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