码迷,mamicode.com
首页 > 其他好文 > 详细

Telerik Reporting

时间:2019-09-25 15:58:03      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:hello   height   inter   scope   restrict   return   ase   less   sys   

Web.Config

<system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer></configuration>

WebApiConfig

Telerik.Reporting.Services.WebApi.ReportsControllerConfiguration.RegisterRoutes(config);

Controller

using System;
using Telerik.Reporting;
using Telerik.Reporting.Cache.File;
using Telerik.Reporting.Services;
using Telerik.Reporting.Services.Engine;
using Telerik.Reporting.Services.WebApi;

namespace Hinfo.SmartPolice.Web.Controllers
{
    public class ReportsController : ReportsControllerBase
    {
        static ReportServiceConfiguration configurationInstance;

        static ReportsController()
        {
            configurationInstance = new ReportServiceConfiguration
            {
                HostAppId = "Hello",
                Storage = new FileStorage(),
                ReportResolver = new MyResolver()
            };
        }

        public ReportsController()
        {
                this.ReportServiceConfiguration = configurationInstance;
        }
        public class MyResolver : IReportResolver
        {
            public ReportSource Resolve(string report)
            {
                return new TypeReportSource { TypeName = report };
            }
        }
     
    }
}

directive

    app.directive("report", function () {
        return {
            restrict: EA,
            transclude: true,
            scope: {
                name: =,
                para: =,
                start: =
            },
            template: <div id="reportViewer1"  style="height:900px;width:100%;overflow: hidden;"/>,
            link: function (scope, element, attrs) {
                scope.$watch(start, function (nv) {
                    if (nv) {
                        scope.start = false;
                        if (element.attr(data-loadover)) {
                            var reportViewer = $("#reportViewer1").data("telerik_ReportViewer");
                            reportViewer.reportSource({
                                report: "Hinfo.Project.Web." + scope.name + ", Hinfo.Project.Web",
                                parameters: scope.para
                            })
                        } else {
                            $("#reportViewer1").telerik_ReportViewer({
                                serviceUrl: "/api/Reports/",
                                templateUrl: /Content/ReportViewer/templates/telerikReportViewerTemplate.html,
                                reportSource: {
                                    report: "Hinfo.Project.Web." + scope.name + ", Hinfo.Project.Web",
                                    parameters: scope.para
                                },
                                viewMode: telerikReportViewer.ViewModes.INTERACTIVE,
                                scaleMode: telerikReportViewer.ScaleModes.SPECIFIC,
                                scale: 1.0,
                                enableAccessibility: false,
                                ready: function () {
                                    element.attr(data-loadover, true);
                                },
                            });
                        }
                    }
                });
            }
        }
    })

Js

 $scope.start = true;
 $scope.name = "ProjectRpt";
 $scope.para = { StartTime: $scope.rpt.StartTime, EndTime: $scope.rpt.EndTime };

html

 <report name="name" para="para" start="start"></report>

 

Telerik Reporting

标签:hello   height   inter   scope   restrict   return   ase   less   sys   

原文地址:https://www.cnblogs.com/m110/p/11584810.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!