本示例说明如何在查看器中显示具有交互作用的 表。 表可以使用不同的交互方式,例如排序、折叠、下钻。 表还可以包含用户要求的参数。
本示例说明如何在查看器中显示具有交互作用的 表。 表可以使用不同的交互方式,例如排序、折叠、下钻。 表还可以包含用户要求的参数。
首先,您需要将StiMvcViewer组件添加到视图页面。您还需要将StiMvcViewerOptions对象传递给构造函数。所需的最少选项是两个操作-GetReport和ViewerEvent,它们位于操作“Actions”选项组中。
@using Stimulsoft.Report.Mvc;...@Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions() { Actions = { GetReport = "GetReport", ViewerEvent = "ViewerEvent" } })
为了演示不同类型的交互式 表,请在 页上添加链接。使用链接中的id参数 表定义。
<table> <tr> <td class="reports" valign="top"> <div style="width: 180px;"> @Html.ActionLink("Sorting", "Index", new { id = "1" }) <br />Report with dynamic sorting <br /><br /> @Html.ActionLink("List Of Products", "Index", new { id = "2" }) <br />Report with drill down <br /><br /> @Html.ActionLink("Group With Collapsing", "Index", new { id = "3" }) <br />Report with collapsing <br /><br /> @Html.ActionLink("Master Detail", "Index", new { id = "4" }) <br />Report with bookmarks <br /><br /> @Html.ActionLink("Selecting Country", "Index", new { id = "5" }) <br />Report with parameters </div> </td> <td style="width: 100%;" valign="top"> @Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions() { Actions = { GetReport = "GetReport", ViewerEvent = "ViewerEvent" } }) </td> </tr></table>
在上面的选项中,我们定义了两个动作,我们需要将其添加到控制器中。
GetReport操作根据URL的id参数加载 表,并使用GetReportResult()静态方法将答案返回给查看器的客户端部分。在此方法的参数中,应传递 表对象。
public ActionResult GetReport(intnbsp;id){ // Create the report object StiReport report = new StiReport(); switch (id) { // Dynamic sorting case 1: report.Load(Server.MapPath("~/Content/Reports/DrillDownSorting.mrt")); break; // Drill down case 2: report.Load(Server.MapPath("~/Content/Reports/DrillDownListOfProducts.mrt")); break; // Collapsing case 3: report.Load(Server.MapPath("~/Content/Reports/DrillDownGroupWithCollapsing.mrt")); break; // Bookmarks case 4: report = new StiMasterDetail(); break; // Parameters case 5: report = new StiParametersSelectingCountryReport(); break; default: report.Load(Server.MapPath("~/Content/Reports/DrillDownSorting.mrt")); break; } // Load data from XML file for report template DataSet data = new DataSet("Demo"); data.ReadXml(Server.MapPath("~/Content/Data/Demo.xml")); report.Dictionary.Databases.Clear(); report.RegData(data); return StiMvcViewer.GetReportResult(report);}
ViewerEvent操作处理所有查看器事件(切换页面、缩放、打印、导出、交互等),并使用ViewerEventResult()静态方法将答案返回给客户端。
public ActionResult ViewerEvent(){ return StiMvcViewer.ViewerEventResult();}
在下面的屏幕截图中,您可以看到示例代码的结果。

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