• Telerik Reporting


    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;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>
  • 相关阅读:
    加法图灵机
    Experiment 1
    进制转换
    快速排序
    辗转相除、线段交点、多角形面积公式
    JS如何优雅监听容器高度变化
    解决react和其他框架之间的交互问题
    MacBook Pro触控板手势
    代理 请求登录失效(显示未登录)问题
    Web端 长按事件
  • 原文地址:https://www.cnblogs.com/m110/p/11584810.html
Copyright © 2020-2023  润新知