Remove export to pdf option in Angular ui-grid

懵懂的女人 提交于 2019-12-10 14:27:42

问题


Is there a way to remove the option to export to pdf from the ui-grid dropdown menu? I want to keep the ability to export to csv, but cannot figure out how to remove the pdf feature without removing all export capability.

I edited this plunker from the docs to remove all of the scripts and JavaScript that are relevant to the pdf exporter. This effectively disables the functionality, but the option to export to a pdf is still available from the menu.

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;
    }
  };

回答1:


On line 12 in your plunker add the following grid option (the default value is true):

 exporterMenuPdf: false,

resulting in something like:

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;
    }
  };

See http://ui-grid.info/docs/#/api/ui.grid.exporter.api:GridOptions for all possible options.




回答2:


Use following option to hide Excel Export option

exporterMenuExcel: false

Detail explanation about this parameters



来源:https://stackoverflow.com/questions/31531155/remove-export-to-pdf-option-in-angular-ui-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!