原創(chuàng)|使用教程|編輯:鄭恭琳|2019-10-31 15:19:23.860|閱讀 260 次
概述:本示例說明了如何以不同的格式加載報(bào)表并在Flash查看器中顯示報(bào)表。可以使用以下格式存儲(chǔ)報(bào)表:報(bào)表模板(.mrt文件)、報(bào)表文檔(.mdc文件)、編譯后的報(bào)表類(.cs或.dll文件)。這些格式中的任何一種都可以加載并顯示在Flash報(bào)表查看器中。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
立即點(diǎn)擊下載Stimulsoft Reports.Net最新版
本示例說明了如何以不同的格式加載報(bào)表并在Flash查看器中顯示報(bào)表??梢允褂靡韵赂袷酱鎯?chǔ)報(bào)表:報(bào)表模板(.mrt文件)、報(bào)表文檔(.mdc文件)、編譯后的報(bào)表類(.cs或.dll文件)。這些格式中的任何一種都可以加載并顯示在Flash報(bào)表查看器中。
首先,您需要將StiMvcViewerFx組件添加到視圖頁面。另外,您需要將StiMvcViewerFxOptions對(duì)象傳遞給構(gòu)造函數(shù)。所需的最少選項(xiàng)是GetReport和ViewerEvent操作。它們位于操作“Actions”選項(xiàng)組中。
@using Stimulsoft.Report.Mvc; ... @Html.Stimulsoft().StiMvcViewerFx(new StiMvcViewerFxOptions() { Actions = { GetReport = "GetReport", ViewerEvent = "ViewerEvent" } })
要演示不同格式的加載報(bào)表,請(qǐng)?jiān)诰W(wǎng)頁上添加鏈接。使用鏈接中的id參數(shù)報(bào)表定義。
<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>
接下來,我們需要在控制器中添加定義的動(dòng)作。
GetReport操作將根據(jù)URL的id參數(shù)加載報(bào)表,并使用GetReportResult()靜態(tài)方法將答案返回到Flash查看器的客戶端。在此方法的參數(shù)中,應(yīng)傳遞報(bào)表對(duì)象。
public ActionResult GetReport(int? 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()靜態(tài)方法將答案返回給客戶端。此操作還用于加載查看器組件的腳本。
public ActionResult ViewerEvent() { return StiMvcViewerFx.ViewerEventResult(); }
在下面的屏幕截圖中,您可以看到示例代碼的結(jié)果。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn