在Angular ui-grid中删除导出为pdf选项

dsa*_*951 5 angularjs angular-ui-grid

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

我从文档中编辑了这个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;
    }
  };
Run Code Online (Sandbox Code Playgroud)

ret*_*eto 27

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

 exporterMenuPdf: false,
Run Code Online (Sandbox Code Playgroud)

导致类似于:

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;
    }
  };
Run Code Online (Sandbox Code Playgroud)

有关所有可能的选项,请参见http://ui-grid.info/docs/#/api/ui.grid.exporter.api:GridOptions.