mvc前后端传值(如何在MVC中将ActiveReports后台参数传递给前台)

mvc前后端传值(如何在MVC中将ActiveReports后台参数传递给前台)

今天给各位分享mvc前后端传值的知识,其中也会对mvc前后端传值进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!



VS2013 + MVC4.0 + ActiveReports10

实现步骤:

1. 创建工程

在 Visual Studio 2013 中创建 MVC Web 项目

2. 创建 Web 服务文件

添加服务,在工程中添加一个【Web 服务】,然后切换到代码视图,修改该类继承的原始类型为 GrapeCity.ActiveReports.Web.ReportService。

public class WebService1 :GrapeCity.ActiveReports.Web.ReportService

PageReport definition1 = (PageReport)base.OnCreateReportHandler(reportPath);

//definition1.Report.ReportParameters[0].DefaultValue.Values[0].ToString();

return definition1;

3. 添加 RDL 报表,并设置为运行时数据源

3.1 为报表添加参数,设置默认值

mvc前后端传值(如何在MVC中将ActiveReports后台参数传递给前台)

3.2 为报表绑定动态时数据源

添加字段:

绑定到数据控件中:

4. 在 Web 服务文件中实现 LocateDocument 方法

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',

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 报表功能、实操案例、技术资源等,您还可携带实际项目场景,和产品经理直接沟通,更快评估试用。

报名视频会议:

快人一步,免费试用

请通过以下方式联系葡萄城,获取 ActiveReports 的免费试用版:

邮件:marketing.xa@grapecity.com

关于葡萄城控件

葡萄城是一家跨国软件研发集团,专注控件领域近30年,是全球最大的控件提供商,也是微软认证的金牌合作伙伴。

关于mvc前后端传值到此分享完毕,希望能帮助到您。

文章版权声明:除非注明,否则均为边学边练网络文章,版权归原作者所有

相关阅读