Skip to content

Commit 5886ca7

Browse files
committed
Merge pull request #4487 from frantisekjandos/exporter-visible-and-selected-menu
Possibility to hide Export selected and Export visible in the grid menu.
2 parents 87cee13 + 63c4c03 commit 5886ca7

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/features/exporter/js/exporter.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,22 @@
371371
*/
372372
gridOptions.exporterMenuAllData = gridOptions.exporterMenuAllData !== undefined ? gridOptions.exporterMenuAllData : true;
373373

374+
/**
375+
* @ngdoc object
376+
* @name exporterMenuVisibleData
377+
* @porpertyOf ui.grid.exporter.api:GridOptions
378+
* @description Add export visible data as cvs/pdf menu items to the ui-grid grid menu, if it's present. Defaults to true.
379+
*/
380+
gridOptions.exporterMenuVisibleData = gridOptions.exporterMenuVisibleData !== undefined ? gridOptions.exporterMenuVisibleData : true;
381+
382+
/**
383+
* @ngdoc object
384+
* @name exporterMenuSelectedData
385+
* @porpertyOf ui.grid.exporter.api:GridOptions
386+
* @description Add export selected data as cvs/pdf menu items to the ui-grid grid menu, if it's present. Defaults to true.
387+
*/
388+
gridOptions.exporterMenuSelectedData = gridOptions.exporterMenuSelectedData !== undefined ? gridOptions.exporterMenuSelectedData : true;
389+
374390
/**
375391
* @ngdoc object
376392
* @name exporterMenuCsv
@@ -539,7 +555,7 @@
539555
this.grid.api.exporter.csvExport( uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE );
540556
},
541557
shown: function() {
542-
return this.grid.options.exporterMenuCsv;
558+
return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuVisibleData;
543559
},
544560
order: 201
545561
},
@@ -549,7 +565,7 @@
549565
this.grid.api.exporter.csvExport( uiGridExporterConstants.SELECTED, uiGridExporterConstants.VISIBLE );
550566
},
551567
shown: function() {
552-
return this.grid.options.exporterMenuCsv &&
568+
return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuSelectedData &&
553569
( this.grid.api.selection && this.grid.api.selection.getSelectedRows().length > 0 );
554570
},
555571
order: 202
@@ -570,7 +586,7 @@
570586
this.grid.api.exporter.pdfExport( uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE );
571587
},
572588
shown: function() {
573-
return this.grid.options.exporterMenuPdf;
589+
return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuVisibleData;
574590
},
575591
order: 204
576592
},
@@ -580,7 +596,7 @@
580596
this.grid.api.exporter.pdfExport( uiGridExporterConstants.SELECTED, uiGridExporterConstants.VISIBLE );
581597
},
582598
shown: function() {
583-
return this.grid.options.exporterMenuPdf &&
599+
return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuSelectedData &&
584600
( this.grid.api.selection && this.grid.api.selection.getSelectedRows().length > 0 );
585601
},
586602
order: 205

src/features/exporter/test/exporter.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ describe('ui.grid.exporter uiGridExporterService', function () {
8686
exporterPdfCustomFormatter: jasmine.any(Function),
8787
exporterHeaderFilterUseName: false,
8888
exporterMenuAllData: true,
89+
exporterMenuVisibleData: true,
90+
exporterMenuSelectedData: true,
8991
exporterMenuCsv: true,
9092
exporterMenuPdf: true,
9193
exporterFieldCallback: jasmine.any(Function),
@@ -114,6 +116,8 @@ describe('ui.grid.exporter uiGridExporterService', function () {
114116
exporterPdfCustomFormatter: callback,
115117
exporterHeaderFilterUseName: true,
116118
exporterMenuAllData: false,
119+
exporterMenuVisibleData: false,
120+
exporterMenuSelectedData: false,
117121
exporterMenuCsv: false,
118122
exporterMenuPdf: false,
119123
exporterFieldCallback: callback,
@@ -139,6 +143,8 @@ describe('ui.grid.exporter uiGridExporterService', function () {
139143
exporterPdfCustomFormatter: callback,
140144
exporterHeaderFilterUseName: true,
141145
exporterMenuAllData: false,
146+
exporterMenuVisibleData: false,
147+
exporterMenuSelectedData: false,
142148
exporterMenuCsv: false,
143149
exporterMenuPdf: false,
144150
exporterFieldCallback: callback,

0 commit comments

Comments
 (0)