【问题标题】:Remove export to pdf option in Angular ui-grid删除 Angular ui-grid 中的导出到 pdf 选项
【发布时间】:2018-05-31 18:55:05
【问题描述】:

有没有办法从 ui-grid 下拉菜单中删除导出为 pdf 的选项?我想保留导出到 csv 的能力,但不知道如何在不删除所有导出功能的情况下删除 pdf 功能。

我从文档中编辑了this plunker,以删除与 pdf 导出器相关的所有脚本和 JavaScript。这有效地禁用了该功能,但仍然可以从菜单中选择导出为 pdf。

app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) {
  $scope.gridOptions = {
    columnDefs: [
      { field: 'name' },
      { field: 'gender', visible: false},
      { field: 'company' }
    ],
    enableGridMenu: true,
    enableSelectAll: true,
    exporterCsvFilename: 'myFile.csv',
    exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
    onRegisterApi: function(gridApi){
      $scope.gridApi = gridApi;
    }
  };

【问题讨论】:

    标签: angularjs angular-ui-grid


    【解决方案1】:

    在您的 plunker 的第 12 行添加以下网格选项(默认值为 true):

     exporterMenuPdf: false,
    

    结果如下:

    app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) {
      $scope.gridOptions = {
        columnDefs: [
          { field: 'name' },
          { field: 'gender', visible: false},
          { field: 'company' }
        ],
        enableGridMenu: true,
        enableSelectAll: true,
        exporterMenuPdf: false, // ADD THIS
        exporterCsvFilename: 'myFile.csv',
        exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
        onRegisterApi: function(gridApi){
          $scope.gridApi = gridApi;
        }
      };
    

    请参阅http://ui-grid.info/docs/#/api/ui.grid.exporter.api:GridOptions 了解所有可能的选项。

    【讨论】:

    • 如何在 angular ui-grid 中删除导出到 Excel 选项
    【解决方案2】:

    使用以下选项隐藏 Excel 导出选项

    exporterMenuExcel: false
    

    Detail explanation about this parameters

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-22
      • 1970-01-01
      • 2018-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多