网站首页 > 博客文章 正文
程序中的参数传递问题,使我们设计程序时,最常遇到的问题。本文主要讲解,如何通过后台为 ActiveReports报表参数赋值,并传递给前台页面元素。
开发环境
VS2013 + MVC4.0 + ActiveReports10
实现步骤:
1. 创建工程
在 Visual Studio 2013 中创建 MVC Web 项目
2. 创建 Web 服务文件
添加服务,在工程中添加一个【Web 服务】,然后切换到代码视图,修改该类继承的原始类型为 GrapeCity.ActiveReports.Web.ReportService。
代码:
public class WebService1 :GrapeCity.ActiveReports.Web.ReportService
{
protected override object OnCreateReportHandler(string reportPath)
{
PageReport definition1 = (PageReport)base.OnCreateReportHandler(reportPath);
//definition1.Report.ReportParameters[0].DefaultValue.Values[0].ToString();
return definition1;
}
}
3. 添加 RDL 报表,并设置为运行时数据源
3.1 为报表添加参数,设置默认值
3.2 为报表绑定动态时数据源
添加字段:
绑定到数据控件中:
4. 在 Web 服务文件中实现 LocateDocument 方法
private void Document_LocateDataSource(object sender, LocateDataSourceEventArgs args)
{
DataTable dt = new DataTable();
dt.Columns.Add("Field1",typeof(int));
dt.Columns.Add("Field2");
dt.Columns.Add("Field3");
dt.Rows.Add(1,"test","test1");
dt.Rows.Add(2, "test", "test1");
dt.Rows.Add(2, "test", "test1");
string temp=args.Report.Parameters[0].CurrentValue.ToString();
args.Data = dt;
}
5. 在 Index 页面中添加 HTML5Viewer,并修改服务文件的 URL
var viewer = GrapeCity.ActiveReports.Viewer({
element: '#viewerContainer',
reportService: {
url: '/WebService1.asmx'
},
uiType: 'desktop',
report: {id:"RdlReport1.rdlx"},
localeUri: 'Scripts/en.txt',
error: function (error) {
console.log("error");
}
});
6. 调用 reportLoaded 方法
打开 RouteConfig.cs 文件,添加以下内容:
routes.IgnoreRoute("{*allActiveReport}", new { allActiveReport = @".*\.ar10(/.*)?" }); routes.IgnoreRoute("WebService1.asmx/{*pathInfo}");
以上就是实现在 MVC 中将 ActiveReports 后台参数传递给前台的具体方法了。
了解更多
参加视频会议,更快掌握ActiveReports报表工具!资深产品经理将详解 ActiveReports 报表功能、实操案例、技术资源等,您还可携带实际项目场景,和产品经理直接沟通,更快评估试用。
报名视频会议:http://www.gcpowertools.com.cn/products/webinars.aspx
快人一步,免费试用
请通过以下方式联系葡萄城,获取 ActiveReports 的免费试用版:
微信:GrapeCityDT
邮件:marketing.xa@grapecity.com
官网:www.gcpowertools.com.cn
关于葡萄城控件
葡萄城是一家跨国软件研发集团,专注控件领域近30年,是全球最大的控件提供商,也是微软认证的金牌合作伙伴。
猜你喜欢
- 2024-12-25 JMeter:断言之响应断言
- 2024-12-25 nginx作用及其配置
- 2024-12-25 动态主机配置协议——DHCP详解
- 2024-12-25 快速掌握和使用Flyway
- 2024-12-25 想了解Python源代码加密吗?现总结如下5大加密混淆手段!
- 2024-12-25 Linux 学习笔记之简单的SSH远程连接配置
- 2024-12-25 Vue基础二——Vue-cli
- 2024-12-25 Zabbix 随笔:6.0 LTS 源码安装
- 2024-12-25 Spring Boot 项目部署方案!打包 + Shell 脚本部署详解,稳的一批
- 2024-12-25 实战 MySQL 高可用架构
你 发表评论:
欢迎- 最近发表
-
- Python 中 必须掌握的 20 个核心函数—len()函数
- 用PLC的指针实现字符串转byte(Codesys平台)一文极简搞懂指针
- EXCEL如何用函数读取复杂字符串中的数据
- 2025-07-19:计算字符串的镜像分数。用go语言,给定一个字符串 s
- 2025-07-10:字符相同的最短子字符串Ⅰ。用go语言,给定一个长度
- 基于物理特征融合与机器学习的多井协同钻井速率实时预测与优化(
- [电子学报文章精选]一种基于特征融合的恶意代码快速检测方法
- 强大的可视化流程图编辑神器 — LogicFlow
- 前端框架太卷了!字节企业级框架Arco Design Mobile开源了
- Vue独立组件——11个最佳Vue.js日期选择器组件
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- flutterrun (59)
- powershellfor (73)
- messagesource (71)
- plsql64位 (73)
- vueproxytable (64)
- npminstallsave (63)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- nacos启动失败 (64)
- ssh-add (70)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- qcombobox样式表 (68)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)