1
1
@ngdoc overview
2
2
@name Tutorial: 121 Grid Menu
3
- @description The grid menu can be enabled through setting the gridOption `enableGridMenu`. This
3
+ @description The grid menu can be enabled through setting the gridOption `enableGridMenu`. This
4
4
adds a settings icon in the top right of the grid, which floats above the column header. The
5
5
menu by default gives access to show/hide columns, but can be customised to show additional
6
- actions.
6
+ actions.
7
7
8
8
You can customize a the menu and provide your own functionality. Each menu item can have:
9
9
10
10
- `shown`: a function that determines whether or not to display the item
11
- - `title`: the title you'd like to have displayed for the menu item (note that you can also
11
+ - `title`: the title you'd like to have displayed for the menu item (note that you can also
12
12
use i18n on this through the `gridMenuTitleFilter` setting)
13
13
- `icon`: an icon you'd like displayed alongside the item
14
14
- `action`: a function that will be called when the menu is clicked
15
15
- `active`: a function that highlights the item (giving a toggle type effect - see the sort on the column menus for an example)
16
- - `context`: by default, the `action`, `shown` and `active`'s' contexts will have a reference to the grid added as the
17
- property `grid` (accessible through `this.grid`. You can pass in your own context by supplying
16
+ - `context`: by default, the `action`, `shown` and `active`'s' contexts will have a reference to the grid added as the
17
+ property `grid` (accessible through `this.grid`. You can pass in your own context by supplying
18
18
the `context` property to your menu item. It will be accessible through `this.context`.
19
19
- `leaveOpen`: by default false, if set to true the menu will be left open after the action
20
20
- `order`: the order in the menu that you wish your item to be. Columns are 300 -> 300 + numColumns * 2,
21
- importer and exporter are 150 and 200 respectively
21
+ importer and exporter are 150 and 200 respectively
22
22
23
23
The exporter feature also adds menu items to this menu. The `exporterMenuCsv` option is set
24
24
to false, which suppresses csv export. The 'export selected rows' option is only available
@@ -27,7 +27,7 @@ if at least one row is selected.
27
27
The column titles can have a custom filter defined using `gridMenuTitleFilter`, used when your
28
28
column headers have an internationalization filter (angular translate or i18nService), and you
29
29
want them also internationalized in the grid menu. The translate needs to return either a string,
30
- or a promise that will resolve to a string. In the example below we create a fake
30
+ or a promise that will resolve to a string. In the example below we create a fake
31
31
internationalization function that waits 1 second then prefixes each column with "col: ".
32
32
33
33
You can suppress the ability to show and hide columns by setting the gridOption `gridMenuShowHideColumns: false`,
@@ -54,7 +54,7 @@ In the meantime, you can override the height to fit with your application in you
54
54
}, 1000, 1);
55
55
return deferred.promise;
56
56
};
57
-
57
+
58
58
$scope.gridOptions = {
59
59
exporterMenuCsv: false,
60
60
enableGridMenu: true,
@@ -75,12 +75,12 @@ In the meantime, you can override the height to fit with your application in you
75
75
],
76
76
onRegisterApi: function( gridApi ){
77
77
$scope.gridApi = gridApi;
78
-
78
+
79
79
// interval of zero just to allow the directive to have initialized
80
80
$interval( function() {
81
81
gridApi.core.addToGridMenu( gridApi.grid, [{ title: 'Dynamic item', order: 100}]);
82
82
}, 0, 1);
83
-
83
+
84
84
gridApi.core.on.columnVisibilityChanged( $scope, function( changedColumn ){
85
85
$scope.columnChanged = { name: changedColumn.colDef.name, visible: changedColumn.colDef.visible };
86
86
});
@@ -141,14 +141,14 @@ In the meantime, you can override the height to fit with your application in you
141
141
it('grid1 grid menu should have 8 items', function () {
142
142
gridTestUtils.expectVisibleGridMenuItems( 'grid1', 7 );
143
143
});
144
-
144
+
145
145
it('grid1 hide then show company column', function () {
146
146
gridTestUtils.expectHeaderColumnCount( 'grid1', 3 );
147
147
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 0, 'Name' );
148
148
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 1, 'Gender' );
149
149
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 2, 'Company' );
150
150
151
- gridTestUtils.clickGridMenuItem( 'grid1', 11 ) // there are some hidden menu items, this is company_hide
151
+ gridTestUtils.clickGridMenuItem( 'grid1', 12 ) // there are some hidden menu items, this is company_hide
152
152
.then(function () {
153
153
gridTestUtils.expectHeaderColumnCount( 'grid1', 2 );
154
154
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 0, 'Name' );
@@ -157,7 +157,7 @@ In the meantime, you can override the height to fit with your application in you
157
157
return gridTestUtils.unclickGridMenu( 'grid1'); // menu stays open if change columns
158
158
})
159
159
.then(function() {
160
- return gridTestUtils.clickGridMenuItem( 'grid1', 12 ); // there are some hidden menu items, this is company_show
160
+ return gridTestUtils.clickGridMenuItem( 'grid1', 13 ); // there are some hidden menu items, this is company_show
161
161
})
162
162
.then(function() {
163
163
gridTestUtils.expectHeaderColumnCount( 'grid1', 3 );
@@ -168,5 +168,5 @@ In the meantime, you can override the height to fit with your application in you
168
168
});
169
169
});
170
170
171
- </file>
172
- </example>
171
+ </file>
172
+ </example>
0 commit comments