找回密码
 立即注册

QQ登录

只需一步,快速开始

yiliukeji

中级会员

16

主题

52

帖子

514

积分

中级会员

积分
514
yiliukeji
中级会员   /  发表于:2017-1-19 13:54  /   查看:2855  /  回复:3
1.页面按钮点击之后调用JS方法


2.在JS方法当中调用后台的Ajax方法

3.在后台的Ajax方法当中给报表参数赋值:

4.结果 不走下面的方法

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

3 个回复

倒序浏览
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2017-1-19 14:36:51
沙发
本帖最后由 Lenka.Guo 于 2017-1-19 14:48 编辑

http://gcdn.gcpowertools.com.cn/showtopic-19954-1-1.html
http://blog.gcpowertools.com.cn/post/HTML5MVC5.aspx

本地直接运行的示例
C:\Users\lenkaguo\Documents\GrapeCity Samples\ActiveReports 11\Professional\ActiveReportsWithMVC5WebAPI\C#

在cshtml页面中编写HTML5Viewer,直接仿照下面这段代码,有三个要点:
1.在head标签中添加js引用
2. 添加css引用
3. 在body里面声明<div id='viewerContainer'>用来加载报表。
  1. @{
  2.     ViewBag.Title = "Home Page";
  3. }

  4. <head>
  5.     <meta charset="utf-8">
  6.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8.     <title>ActiveReports HTML5 viewer - basic sample</title>
  9.     <link href="css/theme-cosmo.css" rel="stylesheet">
  10.     <link href="css/site.css" rel="stylesheet">
  11.     <link href="css/GrapeCity.ActiveReports.Viewer.Html.css" rel="stylesheet">
  12. </head>


  13. @section scripts{
  14.     <script src="~/Scripts/jquery-1.10.2.js"></script>
  15.     <script src="~/Scripts/bootstrap-3.0.0.js"></script>
  16.     <script src="~/Scripts/knockout-2.3.0.js"></script>
  17.     <script src="~/Scripts/GrapeCity.ActiveReports.Viewer.Html.js"></script>
  18.     <script type="text/javascript">
  19.         $(function () {

  20.             var viewer = GrapeCity.ActiveReports.Viewer({
  21.                 element: '#viewerContainer',
  22.                 reportService: {
  23.                     url: '/ActiveReports.ReportService.asmx'
  24.                 },

  25.                 report: {
  26.          id: "PageReport.rdlx"

  27.       },

  28.                 uiType: 'desktop',
  29.             
  30.             $(viewer.toolbar).hide();
  31.            

  32.          

  33.         });
  34.     </script>

  35. }

  36. <body>

  37.   

  38.    
  39.         <div id="viewerContainer">


  40. </body>
复制代码



回复 使用道具 举报
yiliukeji
中级会员   /  发表于:2017-1-19 16:48:27
板凳

假如后台调用的是Controller方法

怎么给报表绑定数据源

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2017-1-19 17:10:51
地板
可以,参考本地示例:C:\Users\lenkaguo\Documents\GrapeCity Samples\ActiveReports 11\Professional\ActiveReportsWithMVC\C#
示例中给出的Controller 运行时绑定数据源
  1. using System.Web.Mvc;
  2. using GrapeCity.ActiveReports.Samples.ActiveReportsWithMVC.Models;
  3. using GrapeCity.ActiveReports.Samples.ActiveReportsWithMVC.Reports;
  4. using System.IO;
  5. namespace GrapeCity.ActiveReports.Samples.ActiveReportsWithMVC.Controllers
  6. {
  7.     public class HomeController : Controller
  8.     {
  9.         private object _reportdata = null;
  10.         /// <summary>
  11.         /// Returns view Index.cshtml
  12.         /// Passes the Entire Customers list to its model
  13.         /// </summary>
  14.         /// <returns>Index.cshtml</returns>
  15.         public ActionResult Index()
  16.         {
  17.             return View("Index", Repository.GetCustomers());
  18.         }
  19.         /// <summary>
  20.         /// Start method
  21.         /// </summary>
  22.         /// <returns></returns>
  23.         public ActionResult Start()
  24.         {
  25.             return Index();
  26.         }
  27.         /// <summary>
  28.         /// Returns View Details.cshtml
  29.         /// </summary>
  30.         /// <param name="id">Customer ID</param>
  31.         /// <returns>Details.cshtml</returns>
  32.         public ActionResult Details(string id)
  33.         {
  34.             return View("Details",Repository.GetCustomer(id) );
  35.         }
  36.         /// <summary>
  37.         /// Returns View Viewer.cshtml
  38.         /// </summary>
  39.         /// <param name="id">Customer id</param>
  40.         /// <param name="reporttype">Section/Page</param>
  41.         /// <returns>Viewer.cshtml</returns>
  42.         public ActionResult ViewReport(string id,string reporttype)
  43.         {
  44.             return View("Viewer", new ReportDescriptor { Id = id, Type = reporttype });
  45.         }
  46.         /// <summary>
  47.         /// Generates Separate Views for Section and Page Reports
  48.         /// </summary>
  49.         /// <param name="reportdesc"></param>
  50.         /// <returns>WebViewer.ascx</returns>
  51.        public ActionResult GetReport(ReportDescriptor reportdesc)
  52.         {
  53.             object report = null;
  54.             switch (reportdesc.Type)
  55.             {
  56.                 case "Section":
  57.                     report = new OrderReport {DataSource= Repository.GetOrders(reportdesc.Id) };
  58.                     break;
  59.                 case "Page":
  60.                     _reportdata = Repository.GetDetails(reportdesc.Id);
  61.                     report = new PageReport(new FileInfo(Server.MapPath("~/Reports/OrderDetailsReport.rdlx")));
  62.                     ((PageReport)(report)).Document.LocateDataSource += Document_LocateDataSource;
  63.                     break;
  64.             }
  65.             ViewData["Report"] = report;
  66.             return PartialView("WebViewer");
  67.         }
  68.        void Document_LocateDataSource(object sender, LocateDataSourceEventArgs args)
  69.        {
  70.            args.Data = _reportdata;
  71.        }
  72.     }
  73. }
复制代码


回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部