DropdownMenu
Description
Initializes the plugin and registers the column header hook needed to inject the dropdown button.
Members
DEFAULT_ITEMS
DropdownMenu.DEFAULT_ITEMS ⇒ Array
Default menu items order when dropdownMenu is enabled by setting the config item to true.
PLUGIN_DEPS
DropdownMenu.PLUGIN_DEPS
Returns the list of plugin dependencies required before this plugin can be initialized.
PLUGIN_KEY
DropdownMenu.PLUGIN_KEY
Returns the plugin key used to identify this plugin in Handsontable settings.
PLUGIN_PRIORITY
DropdownMenu.PLUGIN_PRIORITY
Returns the priority order used to determine the order in which plugins are initialized.
Methods
close
dropdownMenu.close()
Closes dropdown menu.
destroy
dropdownMenu.destroy()
Destroys the plugin instance.
disablePlugin
dropdownMenu.disablePlugin()
Disables the plugin functionality for this Handsontable instance.
enablePlugin
dropdownMenu.enablePlugin()
Enables the plugin functionality for this Handsontable instance.
Emits: Hooks#event:afterDropdownMenuDefaultOptions, Hooks#event:beforeDropdownMenuSetItems
executeCommand
dropdownMenu.executeCommand(commandName, …params)
Executes context menu command.
The executeCommand() method works only for selected cells.
When no cells are selected, executeCommand() doesn’t do anything.
You can execute all predefined commands:
'col_left'- Insert column left'col_right'- Insert column right'clear_column'- Clear selected column'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.
| Param | Type | Description |
|---|---|---|
| commandName | string | Command name to execute. |
| …params | * | Additional parameters passed to the command executor. |
isEnabled
dropdownMenu.isEnabled() ⇒ boolean
Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true then the DropdownMenu#enablePlugin method is called.
open
dropdownMenu.open(position, offset)
Opens the menu and positions it based on the passed coordinates.
Emits: Hooks#event:beforeDropdownMenuShow, Hooks#event:afterDropdownMenuShow
Example
const menu = hot.getPlugin('dropdownMenu');
hot.selectCell(0, 0);menu.open({ top: 50, left: 50 });| Param | Type | Description |
|---|---|---|
| position | Object Event | An object with top and left properties (coordinates relative to the browser viewport, without scroll offsets), or a native browser Event instance (e.g., a MouseEvent). |
| offset | Object | An object that applies an offset to the menu position. |
updatePlugin
dropdownMenu.updatePlugin()
Updates the plugin’s state.
This method is executed when updateSettings() is invoked with any of the following configuration options: