Dropdown menu

优质
小牛编辑
117浏览
2023-12-01

Overview

This plugin allows adding a configurable dropdown menu to the table's column headers.
The dropdown menu acts like the Context Menu, but is triggered by clicking the button in the header.

Quick setup

To enable the plugin, simply set the dropdownMenu property to true, when initializing Handsontable.

var example1 = document.getElementById('example1');

var hot = new Handsontable(example1, {
  data: Handsontable.helper.createSpreadsheetData(3, 7),
  colHeaders: true,
  dropdownMenu: true
});

Plugin configuration

You can use the default dropdown contents by setting it to true, but if you'd like to customize it a little you can set it to use a custom list of actions. For the entry options reference, see the Context Menu demo.

var example2 = document.getElementById('example2');

var hot2 = new Handsontable(example2, {
  data: Handsontable.helper.createSpreadsheetData(3, 7),
  colHeaders: true,
  dropdownMenu: [
    'remove_col',
    '---------',
    'make_read_only',
    '---------',
    'alignment'
  ]
});