This plugin creates the Handsontable Context Menu. It allows to create a new row or column at any place in the
grid among other features.
Possible values:
true
(to enable default options),false
(to disable completely){ uiContainer: containerDomElement }
(to declare a container for all of the Context Menu's dom elements to be placed in)
or array of any available strings:
'row_above'
'row_below'
'col_left'
'col_right'
'remove_row'
'remove_col'
'undo'
'redo'
'make_read_only'
'alignment'
'---------'
(menu item separator)'borders'
(withOptions#customBorders
turned on)'commentsAddEdit'
(withOptions#comments
turned on)'commentsRemove'
(withOptions#comments
turned on)
See the context menu demo for examples.
Example
// as a boolean
contextMenu: true
// as a array
contextMenu: ['row_above', 'row_below', '---------', 'undo', 'redo']
Members
-
staticContextMenu.DEFAULT_ITEMS
-
Context menu default items order when
contextMenu
options is set astrue
.
Methods
-
close()
-
Closes the menu.
-
destroy()
-
Destroys the plugin instance.
-
disablePlugin()
-
Disables the plugin functionality for this Handsontable instance.
-
enablePlugin()
-
Enables the plugin functionality for this Handsontable instance.
-
executeCommand(commandName, params)
-
Execute context menu command.
You can execute all predefined commands:
'row_above'
- Insert row above'row_below'
- Insert row below'col_left'
- Insert column left'col_right'
- Insert column right'clear_column'
- Clear selected column'remove_row'
- Remove row'remove_col'
- Remove column'undo'
- Undo last action'redo'
- Redo last action'make_read_only'
- Make cell read only'alignment:left'
- Alignment to the left'alignment:top'
- Alignment to the top'alignment:right'
- Alignment to the right'alignment:bottom'
- Alignment to the bottom'alignment:middle'
- Alignment to the middle'alignment:center'
- Alignment to the center (justify)
Or you can execute command registered in settings where
key
is your command name.Parameters:
Name Type Description commandName
String The command name to be executed.
params
* repeatable -
isEnabled(){Boolean}
-
Checks if the plugin is enabled in the handsontable settings. This method is executed in
Hooks#beforeInit
hook and if it returnstrue
than theContextMenu#enablePlugin
method is called.Returns: {Boolean}
-
open(position)
-
Opens menu and re-position it based on the passed coordinates.
Parameters:
Name Type Description position
Object | Event An object with
pageX
andpageY
properties which contains values relative to
the top left of the fully rendered content area in the browser or withclientX
andclientY
properties which contains values relative to the upper left edge
of the content area (the viewport) of the browser window.target
property is
also required. This object is structurally compatible with the native mouse event
so it can be used either. -
updatePlugin()
-
Updates the plugin state. This method is executed when
Core#updateSettings
is invoked.