前言
- 此文章仅为记录自己再学习dhtmlxgantt的记录,后期中再开发过程中会不断更新。官方提供的API文档,其实很全,仔细查看阅读都能找到。
- dhtmlxgantt啥都能配置,后面慢慢参照文档就能找到规律。
其它大佬的dhtmlxgantt学习文章:
设置语言
参考文档:
gantt.i18n.setLocale("cn"); //设置中文
设置表格样式
参考文档:
gantt.config.scale_height = 50; //设置表头行高
gantt.config.task_height = 16; //设置任务条高度
gantt.config.row_height = 40; //表格行高
表头内容格式化
gantt.config.scales = [
{unit: "day", step: 1, format: "%j, %D"},
{unit: "month", step: 1, format: "%F, %Y"},
];
添加标记
参考文档:
gantt.plugins({
marker: true // 开启marker插件
});
var date_to_str = gantt.date.date_to_str(gantt.config.task_date);
var today = new Date(2021, 3, 10);
gantt.addMarker({
start_date: today,
css: "today", // 样式名称 也可以时自定义的类,主要设置背景色
text: "今天",
title:"今天: "+ date_to_str(today)
});
自定义灯箱(弹出框)
参考文档