Skip to content

Commit 34a7ac6

Browse files
jmsunseridlgski
authored andcommitted
Option to adjust where the exporter showed up in the menu (#4671)
* Option to adjust where the exporter showed up in the menu I added a new option exporterMenuItemOrder for the gridOptions so that I could adjust where the menu items were showing up in the grid * adding option to adjust grid menu item order adding to the tests to make sure when set to default number and when set to non default number the option still works
1 parent 29c0a36 commit 34a7ac6

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/features/exporter/js/exporter.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,14 @@
235235
* <br/>Defaults to false
236236
*/
237237
gridOptions.exporterOlderExcelCompatibility = gridOptions.exporterOlderExcelCompatibility === true;
238+
/**
239+
* @ngdoc object
240+
* @name exporterMenuItemOrder
241+
* @propertyOf ui.grid.exporter.api:GridOptions
242+
* @description An option to determine the starting point for the menu items created by the exporter
243+
* <br/>Defaults to 200
244+
*/
245+
gridOptions.exporterMenuItemOrder = gridOptions.exporterMenuItemOrder ? gridOptions.exporterMenuItemOrder : 200;
238246
/**
239247
* @ngdoc object
240248
* @name exporterPdfDefaultStyle
@@ -547,7 +555,7 @@
547555
shown: function() {
548556
return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuAllData;
549557
},
550-
order: 200
558+
order: grid.options.exporterMenuItemOrder
551559
},
552560
{
553561
title: i18nService.getSafeText('gridMenu.exporterVisibleAsCsv'),
@@ -557,7 +565,7 @@
557565
shown: function() {
558566
return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuVisibleData;
559567
},
560-
order: 201
568+
order: grid.options.exporterMenuItemOrder + 1
561569
},
562570
{
563571
title: i18nService.getSafeText('gridMenu.exporterSelectedAsCsv'),
@@ -568,7 +576,7 @@
568576
return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuSelectedData &&
569577
( this.grid.api.selection && this.grid.api.selection.getSelectedRows().length > 0 );
570578
},
571-
order: 202
579+
order: grid.options.exporterMenuItemOrder + 2
572580
},
573581
{
574582
title: i18nService.getSafeText('gridMenu.exporterAllAsPdf'),
@@ -578,7 +586,7 @@
578586
shown: function() {
579587
return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuAllData;
580588
},
581-
order: 203
589+
order: grid.options.exporterMenuItemOrder + 3
582590
},
583591
{
584592
title: i18nService.getSafeText('gridMenu.exporterVisibleAsPdf'),
@@ -588,7 +596,7 @@
588596
shown: function() {
589597
return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuVisibleData;
590598
},
591-
order: 204
599+
order: grid.options.exporterMenuItemOrder + 4
592600
},
593601
{
594602
title: i18nService.getSafeText('gridMenu.exporterSelectedAsPdf'),
@@ -599,7 +607,7 @@
599607
return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuSelectedData &&
600608
( this.grid.api.selection && this.grid.api.selection.getSelectedRows().length > 0 );
601609
},
602-
order: 205
610+
order: grid.options.exporterMenuItemOrder + 5
603611
}
604612
]);
605613
},

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ describe('ui.grid.exporter uiGridExporterService', function () {
9292
exporterMenuPdf: true,
9393
exporterFieldCallback: jasmine.any(Function),
9494
exporterAllDataFn: null,
95-
exporterSuppressColumns: []
95+
exporterSuppressColumns: [],
96+
exporterMenuItemOrder: 200
9697
});
9798
});
9899

@@ -122,7 +123,8 @@ describe('ui.grid.exporter uiGridExporterService', function () {
122123
exporterMenuPdf: false,
123124
exporterFieldCallback: callback,
124125
exporterAllDataPromise: callback,
125-
exporterSuppressColumns: [ 'buttons' ]
126+
exporterSuppressColumns: [ 'buttons' ],
127+
exporterMenuItemOrder: 75
126128
};
127129
uiGridExporterService.defaultGridOptions(options);
128130
expect( options ).toEqual({
@@ -150,7 +152,8 @@ describe('ui.grid.exporter uiGridExporterService', function () {
150152
exporterFieldCallback: callback,
151153
exporterAllDataFn: callback,
152154
exporterAllDataPromise: callback,
153-
exporterSuppressColumns: [ 'buttons' ]
155+
exporterSuppressColumns: [ 'buttons' ],
156+
exporterMenuItemOrder: 75
154157
});
155158
});
156159
});

0 commit comments

Comments
 (0)