网格中的内联编辑
dhtmlxGantt 提供两种编辑内容的选项:
- 通过使用 Lightbox 编辑表单
- 通过在 Grid 区域中使用内联编辑器
内联编辑让你直接在网格中进行任何修改:创建与更新任务,设置它们之间的连接,定义开始和结束日期,或修改持续时间——全部通过内置编辑器完成。

要启用内联编辑,你需要:
- 指定编辑器配置列表,并使用编辑器对象的 map_to 属性将所需的编辑器映射到网格列
const textEditor = { type: "text", map_to: "text" };
const dateEditor = { type: "date", map_to: "start_date", min: new Date(2025, 0, 1),
max: new Date(2026, 0, 1) };
const durationEditor = { type: "number", map_to: "duration", min: 0, max: 100 };
- 在列配置中使用 editor 属性来定义该列应使用的编辑器
gantt.config.columns = [
{ name: "text", tree: true, width: "*", editor: textEditor, resize: true },
{ name: "start_date", align: "center", editor: dateEditor, resize: true },
{ name: "duration", align: "center", editor: durationEditor },
{ name: "add", width: 44 }
];
注释
请在 Inline Editors Extension 文章中查看 inlineEditors 对象 API 的详细信息。
你也可以查看视频指南,了解如何在网格中实现内联编辑。