主页

handsontable contextMenu 增加自定义菜单

2025-08-25 04:47PM

在Handsontable中,通过自定义contextMenu(右键菜单)来实现在表格增加自定义菜单

例如:

import React, { useRef } from 'react';
import Handsontable from 'handsontable';
import 'handsontable/dist/handsontable.full.css';
import 'handsontable-context-menu/dist/handsontable-contextMenu.min.css';
import { HotTable } from '@handsontable/react';

const App = () => {
  const hotTableRef = useRef(null);

  const data = [
    ['', 'Ford', 'Volvo', 'Toyota', 'Honda'],
    ['2019', 10, 11, 12, 130],
    ['2020', 20, 11, 14, 130],
    ['2021', 30, 15, 12, 130],
  ]; // 使用英文分号

  return (
    <div>
      <HotTable
        ref={hotTableRef}
        data={data}
        colHeaders={true}
        rowHeaders={true}
        contextMenu={true}
        licenseKey="non-commercial-and-evaluation"
      />
    </div>
  );
};

export default App;

页面展示

 

返回>>

登录

请登录后再发表评论。

评论列表:

目前还没有人发表评论