HeaderMenu
Feature
Right click column header or focus it and press SPACE key to show the context menu for headers.
Default header menu items
The Header menu has no default items provided by the HeaderMenu feature, but there are other features that populate the header menu with the following items:
| Reference | Text | Weight | Feature | Description |
|---|---|---|---|---|
filter |
Filter | 100 | Filter | Shows the filter popup to add a filter |
filterEdit |
Edit filter | 100 | Filter | Shows the filter popup to change/remove a filter |
filterRemove |
Remove filter | 110 | Filter | Stops filtering by selected column field |
toggleFilterBar |
Hide filter bar / Show filter bar | 120 | FilterBar | Toggles filter bar visibility |
columnPicker |
Columns | 200 | ColumnPicker | Shows a submenu to control columns visibility |
>column.id* |
column.text* | ColumnPicker | Check item to hide/show corresponding column | |
pinColumn |
Pin column | 250 | PinColumns | Shows a submenu to pin/unpin the column |
hideColumn |
Hide column | 210 | ColumnPicker | Hides selected column |
rename |
Rename column text | 215 | ColumnRename | Edits the header text of the column |
toggleCollapse |
Collapse column / Expand column | 215 | This feature | Expands or collapses a collapsible column |
movePrev |
Move previous | 220 | This feature | Moves selected column before its previous sibling |
moveNext |
Move next | 230 | This feature | Moves selected column after its next sibling |
sortAsc |
Sort ascending | 300 | Sort | Sort by the column field in ascending order |
sortDesc |
Sort descending | 310 | Sort | Sort by the column field in descending order |
multiSort |
Multi sort | 320 | Sort | Shows a submenu to control multi-sorting |
>addSortAsc |
Add ascending sorting | 330 | Sort | Adds ascending sorter using the column field |
>addSortDesc |
Add descending sorting | 340 | Sort | Adds descending sorter using the column field |
>removeSorter |
Remove sorter | 350 | Sort | Stops sorting by selected column field |
groupAsc |
Group ascending | 400 | Group | Group by the column field in ascending order |
groupDesc |
Group descending | 410 | Group | Group by the column field in descending order |
groupRemove |
Stop grouping | 420 | Group | Stops grouping |
mergeCells |
Merge cells | 500 | MergeCells | Merge cells with same value in a sorted column |
- *
- items that are generated dynamically
- >
- first level of submenu
Customizing the menu items
The menu items in the Header menu can be customized, existing items can be changed or removed, and new items can be added. This is handled using the items config of the feature.
Add extra items for all columns:
const grid = new Grid({
features : {
headerMenu : {
items : {
extraItem : { text: 'My header item', icon: 'fa fa-car', weight: 200, onItem : () => ... }
}
}
}
});
It is also possible to add items using columns config. See examples below.
Add extra items for a single column:
const grid = new Grid({
columns: [
{
field: 'name',
text: 'Name',
headerMenuItems: {
columnItem : { text: 'My unique header item', icon: 'fa fa-flask', onItem : () => ... }
}
}
]
});
Remove built-in item:
const grid = new Grid({
features : {
headerMenu : {
items : {
// Hide 'Stop grouping'
groupRemove : false
}
}
}
});
Customize built-in item:
const grid = new Grid({
features : {
headerMenu : {
items : {
hideColumn : {
text : 'Bye bye column'
}
}
}
}
});
Remove nested menu item:
const grid = new Grid({
features : {
headerMenu : {
items : {
multiSort : {
menu : { removeSorter : false }
}
}
}
}
});
It is also possible to manipulate the default items and add new items in the processing function:
const grid = new Grid({
features : {
headerMenu : {
processItems({items, record}) {
if (record.cost > 5000) {
items.myItem = { text : 'Split cost' };
}
}
}
}
});
Full information of the menu customization can be found in the "Customizing the Cell menu and the Header menu" guide.
This feature is enabled by default.
Keyboard shortcuts
This feature has the following default keyboard shortcuts:
| Keys | Action | Action description |
|---|---|---|
| Space | showContextMenuByKey | Shows context menu for currently focused header |
| Ctrl+Space | showContextMenuByKey | Shows context menu for currently focused header |
For more information on how to customize keyboard shortcuts, please see our guide
targetElement.innerHTML = '<p>Right click a header to display a context menu</p>'; const grid = new Grid({ appendTo : targetElement, // makes grid as high as it needs to be to fit rows autoHeight : true, features : { // this feature is enabled by default, // so no need for this unless you have changed defaults headerMenu : true }, data : DataGenerator.generateData(5), columns : [ { field : 'name', text : 'Name', flex : 1 }, { field : 'score', text : 'Score', flex : 1 } ] }); See also
- CellMenu - Context menu for cells
- headerMenuItems - Per-column header menu items
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
keyMap : Object<String, KeyMapConfig>
See Keyboard shortcuts for details
-
A CSS selector targeting an element, such as an ellipsis icon that when clicked will trigger the menu to show.
-
Set to
trueto prevent the native menu from showing when there are no menu items to show, or you manually prevent the menu from showing in an event listener.Has a corresponding runtime preventNativeMenu property.
-
Event which is used to show context menu. Available options are: 'contextmenu', 'click' and 'dblclick'. Default value is used from contextMenuTriggerEvent
-
This is a type of the context menu used to generate correct names for methods and events. Should be in camel case. Required to be set in subclass.
-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of HeaderMenu class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of ContextMenuBase class, or subclass thereof.
-
Identifies an object as an instance of HeaderMenu class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Returns the base, configured-in menu items set from the configured items, taking into account the namedItems the feature offers.
-
Set to
trueto prevent the native menu from showing when there are no menu items to show, or you manually prevent the menu from showing in an event listener.Has a corresponding preventNativeMenu config.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Hides the context menu
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.