找回密码
 立即注册

QQ登录

只需一步,快速开始

zqhuang

注册会员

4

主题

28

帖子

102

积分

注册会员

积分
102
QQ
最新发帖
zqhuang
注册会员   /  发表于:2020-7-7 09:40  /   查看:3077  /  回复:5
1金币
本帖最后由 zqhuang 于 2020-7-22 10:20 编辑


A14 根据api文档加入自定义工具栏按钮报错是什么原因?


  1.         

  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5.     <title>Reports Designer</title>
  6.     <meta charset="utf-8">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1">
  8.     <meta http-equiv="x-ua-compatible" content="ie=edge">

  9.     <!-- No Virtual Directory -->
  10.     <base href="/">

  11.     <!-- For Virtual Directory -->
  12.     <!--<base href="/VirtualDirectoryName/">-->

  13.     <link rel="stylesheet" href="/vendor/css/materialdesignicons.min.css" media="all" type="text/css" />
  14.     <link rel="stylesheet" href="/vendor/css/fonts-googleapis.css" type="text/css" />
  15.     <link rel="stylesheet" href="/jsViewer.min.css" />

  16.     <style type="text/css">
  17.         .gcv-pageview {
  18.             overflow: auto;
  19.             width: 100%;
  20.             height: 100%;
  21.             padding-top: 0px;
  22.         }

  23.         .gcv-page {
  24.             position: relative;
  25.             overflow: hidden;
  26.             margin: 0 auto 0px auto;
  27.             background-color: white;
  28.             box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.05);
  29.         }
  30.     </style>
  31.     <link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png" />
  32.     <link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png" />
  33.     <link rel="shortcut icon" href="/icons/favicon.ico" />

  34. </head>
  35. <body class="theme-blue">
  36.     <div id="viewer-id" style="width: 100%; height: 100%;">
  37.         <style type="text/css">
  38.             * {
  39.                 box-sizing: border-box;
  40.                 -moz-box-sizing: border-box;
  41.                 -webkit-box-sizing: border-box
  42.             }

  43.             .reportPage {
  44.                 background-color: #fff;
  45.                 overflow: hidden
  46.             }

  47.             .canvasItem {
  48.                 line-height: normal
  49.             }

  50.             .canvasItem, .itemContent {
  51.                 position: absolute
  52.             }

  53.             .listItem, .section {
  54.                 position: relative
  55.             }

  56.             .placeItem {
  57.                 position: absolute;
  58.                 z-index: inherit
  59.             }

  60.             .tableItem {
  61.                 border-collapse: collapse;
  62.                 table-layout: fixed
  63.             }

  64.             .tableCell {
  65.                 padding: 0;
  66.                 vertical-align: top;
  67.             }

  68.             @-moz-document url-prefix() {
  69.                 .tableCell {
  70.                     height: 100%
  71.                 }
  72.             }

  73.             .cellContent {
  74.                 position: relative;
  75.                 height: 100%;
  76.                 overflow: hidden
  77.             }

  78.             .cbChecked, .cbUnchecked {
  79.                 width: 12px;
  80.                 height: 12px;
  81.                 flex-basis: 12px;
  82.                 font-size: 10px;
  83.                 border-width: 1px;
  84.                 border-style: solid;
  85.                 text-align: center;
  86.                 flex-grow: 0;
  87.                 flex-shrink: 0
  88.             }

  89.                 .cbChecked:after {
  90.                     content: "\2714";
  91.                     vertical-align: top
  92.                 }

  93.             .cbCommon {
  94.                 width: 100%;
  95.                 height: 100%;
  96.                 overflow: hidden;
  97.                 display: flex;
  98.                 flex-direction: column;
  99.                 justify-content: flex-start;
  100.                 align-items: center;
  101.                 text-align: center
  102.             }

  103.             .cbTopLeft {
  104.                 align-items: flex-start;
  105.                 text-align: left
  106.             }

  107.             .cbTopRight {
  108.                 align-items: flex-end;
  109.                 text-align: right
  110.             }

  111.             .cbMiddleLeft {
  112.                 flex-direction: row;
  113.                 text-align: left
  114.             }

  115.             .cbMiddleCenter {
  116.                 flex-direction: row;
  117.                 justify-content: center
  118.             }

  119.             .cbMiddleRight {
  120.                 flex-direction: row-reverse;
  121.                 text-align: right
  122.             }

  123.             .cbBottomLeft {
  124.                 align-items: flex-start;
  125.                 text-align: left
  126.             }

  127.             .cbBottomCenter, .cbBottomLeft, .cbBottomRight {
  128.                 flex-direction: column-reverse
  129.             }

  130.             .cbBottomRight {
  131.                 align-items: flex-end;
  132.                 text-align: right
  133.             }

  134.             .cbTextCommon {
  135.                 width: 100%
  136.             }

  137.             .cbTextBottomLeft, .cbTextTopLeft {
  138.                 padding-left: 14px
  139.             }

  140.             .cbTextBottomRight, .cbTextTopRight {
  141.                 padding-right: 14px
  142.             }

  143.             .cbTextMiddleLeft {
  144.                 padding-left: 2px;
  145.                 width: calc(100% - 2px)
  146.             }

  147.             .cbTextMiddleCenter {
  148.                 position: absolute
  149.             }

  150.             .cbTextMiddleRight {
  151.                 padding-right: 2px;
  152.                 width: calc(100% - 2px)
  153.             }

  154.             .textBoxItem {
  155.                 display: flex;
  156.                 position: absolute
  157.             }

  158.             .textBoxContent {
  159.                 width: 100%;
  160.                 max-height: 100%;
  161.                 overflow: hidden;
  162.                 text-decoration: inherit
  163.             }

  164.             .hideOverflow {
  165.                 overflow: hidden
  166.             }

  167.             .action {
  168.                 cursor: pointer;
  169.                 text-decoration: inherit
  170.             }

  171.                 .action.toggle {
  172.                     font-size: 75%
  173.                 }

  174.                     .action.toggle.expanded:after {
  175.                         content: "\2795"
  176.                     }

  177.                     .action.toggle.collapsed:after {
  178.                         content: "\2796"
  179.                     }

  180.             .tocLevelLabel, .tocLevelNumber {
  181.                 float: left;
  182.                 text-decoration: inherit
  183.             }

  184.             .tocLevelNumber {
  185.                 text-align: left
  186.             }

  187.             .tocPageNumber {
  188.                 float: right;
  189.                 text-decoration: inherit
  190.             }

  191.             .tocPageNumberNoFill {
  192.                 float: left;
  193.                 padding-left: 2pt;
  194.                 text-decoration: inherit
  195.             }

  196.             .bordersItem {
  197.                 pointer-events: none
  198.             }

  199.             .errorMessage {
  200.                 font-size: 10pt;
  201.                 color: #000;
  202.                 padding: 2pt
  203.             }

  204.             .gcdv-tooltip {
  205.                 position: absolute;
  206.                 z-index: 1000;
  207.                 top: 0;
  208.                 left: 0;
  209.                 pointer-events: none;
  210.                 max-width: 400px;
  211.                 padding: 6px;
  212.                 background-color: #ffffe5;
  213.                 border: 1px solid rgba(0,0,0,.1);
  214.                 border-radius: 6px;
  215.                 box-shadow: 0 6px 12px rgba(0,0,0,.175);
  216.                 box-sizing: border-box
  217.             }

  218.             .spinner {
  219.                 position: fixed;
  220.                 top: calc(50% - 9px);
  221.                 left: calc(50% - 35px);
  222.                 width: 70px;
  223.                 text-align: center;
  224.             }

  225.             #root {
  226.                 background-color: #e5e5e5;
  227.             }

  228.             .spinner > div {
  229.                 width: 18px;
  230.                 height: 18px;
  231.                 background-color: #333;
  232.                 border-radius: 100%;
  233.                 display: inline-block;
  234.                 -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
  235.                 animation: sk-bouncedelay 1.4s infinite ease-in-out both;
  236.             }

  237.             .spinner .bounce1 {
  238.                 -webkit-animation-delay: -0.32s;
  239.                 animation-delay: -0.32s;
  240.             }

  241.             .spinner .bounce2 {
  242.                 -webkit-animation-delay: -0.16s;
  243.                 animation-delay: -0.16s;
  244.             }

  245.             @-webkit-keyframes sk-bouncedelay {
  246.                 0%, 80%, 100% {
  247.                     -webkit-transform: scale(0)
  248.                 }

  249.                 40% {
  250.                     -webkit-transform: scale(1.0)
  251.                 }
  252.             }

  253.             @keyframes sk-bouncedelay {
  254.                 0%, 80%, 100% {
  255.                     -webkit-transform: scale(0);
  256.                     transform: scale(0);
  257.                 }

  258.                 40% {
  259.                     -webkit-transform: scale(1.0);
  260.                     transform: scale(1.0);
  261.                 }
  262.             }
  263.         </style>

  264.         <div class="spinner">
  265.             <div class="bounce1"></div>
  266.             <div class="bounce2"></div>
  267.             <div class="bounce3"></div>
  268.         </div>
  269.     </div>

  270.     <script src="/vendor/js/jquery.min.js"></script>
  271.     <script src="/vendor/js/bootstrap.min.js"></script>
  272.     <script src="/baseServerApi.js"></script>
  273.     <script src="/file-dialog.js"></script>
  274.     <script src="/data-set-picker.js"></script>
  275.     <script src="/file-view.js"></script>
  276.     <script src="/viewer-container.js"></script>
  277.     <script src="/ar-datasource-editor.js"></script>
  278.     <script src="/web-designer.js"></script>

  279.     <script src="/jsViewer.min.js"></script>
  280.    
  281.     <script type="text/javascript">
  282.         var viewer = GrapeCity.ActiveReports.JSViewer.create({
  283.             element: '#viewer-id',
  284.             reportService: {
  285.                 url: '/api/reporting',
  286.             },
  287.             //reportID: 'test.rdlx;test;{"PrintMan":"PrintMan","Id":2}',
  288.             settings: {
  289.                 zoomType: 'FitPage'
  290.             }
  291.             ,
  292.             documentLoaded: function () {
  293.                 //viewer.print();
  294.                 $("#main_toolbar_Item_7").hide();
  295.                 $("#main_toolbar_Item_8").hide();
  296.                 $("#main_toolbar_Item_9").hide();
  297.                 $("#main_toolbar_Item_10").hide();
  298.                 $("#main_toolbar_Item_11").hide();
  299.                 $("#main_toolbar_Item_12").hide();
  300.                 $("#main_toolbar_Item_13").hide();
  301.                 $("#main_toolbar_Item_14").hide();
  302.                 $("#main_toolbar_Item_17").hide();
  303.                 $("#main_toolbar_Item_18").hide();
  304.                 $("#main_toolbar_Item_19").hide();
  305.             }
  306.         });
  307.         viewer.openReport('test.rdlx;test;{"PrintMan":"PrintMan","Id":2}', [{ name: 'BelongId', values: [0] }])

  308.         if ('0' == '0') {
  309.             $(".gcv-menu").hide();
  310.         }

  311.         if ('1' == '0') {
  312.             $(".gcv-header-container").hide();
  313.         };
  314.         var icon = `
  315.    
  316. `;
  317.         var svgPdfExportButton = {
  318.             key: '$pdfExportButtonKey',
  319.             icon: { type: 'svg', content: icon },
  320.             enabled: true,
  321.             action: function (item) {
  322.                 alert("OK")
  323.             },
  324.             onUpdate: function (arg, item) {
  325.             }
  326.         }

  327.         viewer.toolbar.addItem(svgPdfExportButton);

  328.     </script>
  329. </body>
  330. </html>

  331.         
复制代码


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

最佳答案

查看完整内容

您好,这个我已经试过,好像也有同样的问题,正在跟研发积极沟通中 参考写法: 这样写: viewer.toolbar.desktop.addItem(pdfExportButton);[/backcolor] //or[/backcolor] viewer.toolbar.desktop.addItem(svgPdfExportButton);[/backcolor]

5 个回复

倒序浏览
最佳答案
最佳答案
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-7-7 09:40:28
来自 4#
本帖最后由 KearneyKang 于 2020-7-9 16:11 编辑

您好,这个我已经试过,好像也有同样的问题,正在跟研发积极沟通中
参考写法:
这样写:
viewer.toolbar.desktop.addItem(pdfExportButton);
//or
viewer.toolbar.desktop.addItem(svgPdfExportButton);
  1. <script type="text/javascript">
  2.     var viewer = GrapeCity.ActiveReports.JSViewer.create({
  3.         element: '#viewerContainer',
  4.         reportID: 'RDL报表.rdlx;123;456', //报表名称和参数的传递
  5.         //availableExports: ['Xml', 'Pdf'],

  6.         reportService: {},
  7.         renderMode: 'Galley',
  8.         // other properties
  9.         documentLoaded: () => {        
  10.             //   //viewer.print();
  11.             //   //$("#main_toolbar_Item_17").hide();
  12.             //   //$("#main_toolbar_Item_18").hide();
  13.             //   //$("#main_toolbar_Item_19").hide();
  14.             //viewer.export('XLSX', null, true, { FileName: '1997 Annual Report1', Multisheet: false,LayoutMode:"Galley" })
  15.             //viewer.toolbar.toggle(false)
  16.         }
  17.     });



  18. var pdfExportButton = {
  19.     key: '$pdfExportButtonKey',
  20.     iconCssClass: 'mdi mdi-file-pdf',
  21.     enabled: true,
  22.     action: function(item) {
  23.         console.log('Export to PDF function works here');
  24.     },
  25.     onUpdate: function(arg, item) {
  26.         console.log('Something in viewer was updated, check/update button state here');
  27.     }
  28. };


  29. //OR button with svg as icon
  30. var icon = `
  31. `;
  32. var svgPdfExportButton = {
  33.     key: '$pdfExportButtonKey',
  34.     icon: {type: 'svg', content: icon},
  35.     enabled: true,
  36.     action: function(item) {
  37.         console.log('Export to PDF function works here');
  38.     },
  39.     onUpdate: function(arg, item) {
  40.         console.log('Something in viewer was updated, check/update button state here');
  41.     }
  42. }


  43. viewer.toolbar.desktop.addItem(pdfExportButton);
  44. //or
  45. viewer.toolbar.desktop.addItem(svgPdfExportButton);
  46. viewer.toolbar.desktop.removeItem('$zoom');
  47. viewer.toolbar.desktop.removeItem('$print');
  48. viewer.toolbar.desktop.removeItem('$pdfExportButtonKey');
  49. </script>
复制代码

回复 使用道具 举报
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-7-7 14:21:35
2#
您好,你现在遇到的问题是给报表工具栏添加自定义的按钮报错是吧,问题已经收到,我这边需要去测试验证下。这个可能需要一点时间
回复 使用道具 举报
zqhuang
注册会员   /  发表于:2020-7-9 09:03:15
3#
KearneyKang 发表于 2020-7-7 14:21
您好,你现在遇到的问题是给报表工具栏添加自定义的按钮报错是吧,问题已经收到,我这边需要去测试验证下。 ...

这个问题现在能怎么解决?
回复 使用道具 举报
zqhuang
注册会员   /  发表于:2020-7-10 08:51:24
5#
KearneyKang 发表于 2020-7-9 09:11
您好,这个我已经试过,好像也有同样的问题,正在跟研发积极沟通中
参考写法:
这样写:

可以了,还想问下就是下面这个属性,可以赋值的值有哪些?
  iconCssClass: 'mdi mdi-file-pdf',
回复 使用道具 举报
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-7-10 09:14:52
6#
这个我这边暂时也不是很清楚,昨天也是刚刚知道原来的写法不行,要使用这种新的方法来添加按钮
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部