Column menu Display a configurable dropdown menu, triggered by clicking on a button in a column header.
Overview The DropdownMenu
plugin enables you to add 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, set the dropdownMenu
configuration option to true
when initializing Handsontable.
Plugin configuration To use the default dropdown contents, set it to true
, or to customize it by setting it to use a custom list of actions. For the available entry options reference, see the Context Menu demo .
import { HotTable } from '@handsontable/react';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/dist/handsontable.full.min.css';
// register Handsontable's modules
registerAllModules();
export const ExampleComponent = () => {
return (
<HotTable
data={[
['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1'],
['A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2'],
['A3', 'B3', 'C3', 'D3', 'E3', 'F3', 'G3'],
]}
colHeaders={true}
licenseKey="non-commercial-and-evaluation"
height="auto"
dropdownMenu={[
'remove_col',
'---------',
'make_read_only',
'---------',
'alignment'
]}
/>
);
};
ReactDOM.render(<ExampleComponent />, document.getElementById('example2'));
<script src="https://cdn.jsdelivr.net/npm/handsontable@13.1/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@13.1/dist/handsontable.full.min.css" />
<script src="https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@handsontable/react@13.1/dist/react-handsontable.min.js"></script>
<script src="https://handsontable.com/docs/13.1/scripts/fixer.js"></script>
<div id="example2" class="hot "></div>
Related articles Configuration options:
Hooks:
Plugins:
Last update: Nov 20, 2024