您好,
将testrpt.aspx这个文件,修改如下- <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
- <%@ Register Assembly="GrapeCity.ActiveReports.Web.v9, Version=9.4.4727.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" Namespace="GrapeCity.ActiveReports.Web" TagPrefix="ActiveReportsWeb" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head id="Head1" runat="server">
- <title>testrpt</title>
- <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
- <script language="javascript" type="text/javascript">
- var exportSelect = '<select id="ExportSelect" style="width:80px"><option selected disabled>Export</option><option value="PDF" style="background: url(images/pdf.png) right no-repeat; width: 50px">PDF</option><option value="Excel" style="background: url(images/Excel.gif) right no-repeat; width: 50px">Excel</option></select>';
- $(document).ready(function () {
- var toolbar = $('#WebViewer').find('.arvToolBar');
- toolbar.append(exportSelect);
- toolbar.append("<span><input id='btnPrint' type='Button' value='Print'/></span>");
- var viewModel = GetViewModel("WebViewer");
- //Check the selected value in DropDown and Export
- $("#btnPrint").click(function () {
- if (viewModel.PageLoaded()) {
- viewModel.Print();
- }
- });
- $("#ExportSelect").change(function (e, args) {
- var valueSelected = this.value;
- if (viewModel.PageLoaded()) {
- switch (valueSelected) {
- case "PDF":
- viewModel.Export(ExportType.Pdf, function (uri) {
- window.location = uri;
- }, true);
- break;
- case "Excel":
- viewModel.Export(ExportType.Xls, function (uri) {
- window.location = uri;
- }, true);
- break;
- }
- }
- });
- });
- </script>
- </head>
- <body>
- <div>
- <ActiveReportsWeb:WebViewer ID="WebViewer" runat="server" Height="600" Width="100%" onload="WebViewer_Load" ViewerType="HtmlViewer">
- <FlashViewerOptions MultiPageViewColumns="1" MultiPageViewRows="1"
- ResourceUrl="/Grapecity.ActiveReports.Flash.v9.Resources.swf"
- Url="/Grapecity.ActiveReports.Flash.v9.swf" ResourceLocale="zh_CN"></FlashViewerOptions>
- </ActiveReportsWeb:WebViewer>
- </div>
- </body>
- </html>
- <script runat="server">
- protected void WebViewer_Load(object sender, EventArgs e)
- {
- WebViewer.Report = ViewData["Report"];
- }
- </script>
复制代码 |