var editors = {    text: {type: "text", map_to: "text"},    start_date: {type: "date", map_to: "start_date", min: new Date(2018, 0, 1),        max: new Date(2019, 0, 1)},    end_date: {type: "date", map_to: "end_date", min: new Date(2018, 0, 1),        max: new Date(2019, 0, 1)},    duration: {type: "number", map_to: "duration", min:0, max: 100},    priority: {type:"select", map_to:"priority", options:gantt.serverList("priority")},    predecessors: {type: "predecessor", map_to: "auto"}};
const dateEditor = {type: "date", map_to: "start_date",    min: function(taskId){      return gantt.getState().min_date    },    max: function( taskId ){      return gantt.getState().max_date    }};
// inclusive editor for end dates// use the default editor, but override the set_value/get_value methodsvar dateEditor = gantt.config.editor_types.date;gantt.config.editor_types.end_date = gantt.mixin({   set_value: function(value, id, column, node){        var correctedValue = gantt.date.add(value, -1, "day");        return dateEditor.set_value.apply(this, [correctedValue, id, column, node]);   },   get_value: function(id, column, node) {        var selectedValue = dateEditor.get_value.apply(this, [id, column, node]);        return gantt.date.add(selectedValue, 1, "day");   },}, dateEditor);var textEditor = {type: "text", map_to: "text"};var startDateEditor = {type: "date", map_to: "start_date"};var endDateEditor = {type: "end_date", map_to: "end_date"};var durationEditor = {type: "number", map_to: "duration", min:0, max: 100};gantt.config.columns = [    {name: "text", label: "Name", tree: true, width: 200, editor: textEditor,        resize: true},    {name: "duration", label: "Duration", width:80, align: "center",        editor: durationEditor, resize: true},    {name: "start_date", label: "Start", width:140, align: "center",        editor: startDateEditor, resize: true},    {name: "end_date", label: "Finish", width:140, align: "center",        editor: endDateEditor, resize: true}];// change lightbox and grid templates to display dates of tasks in an inclusive formatgantt.templates.task_end_date = function(date){    return gantt.templates.task_date(new Date(date.valueOf() - 1));};var gridDateToStr = gantt.date.date_to_str("%Y-%m-%d");gantt.templates.grid_date_format = function(date, column){    if(column === "end_date"){        return gridDateToStr(new Date(date.valueOf() - 1));    }else{        return gridDateToStr(date);    }}

dhtmlxGantt是用于跨浏览器和跨平台应用程序的功能齐全的Gantt图表,可满足项目管理控件应用程序的所有需求,是最完善的甘特图图表库。了解更多DhtmlxGantt相关内容和资讯,欢迎在线咨询或者私信我获取正版试用版及 价。


甘特图控件交流群:764148812    欢迎进群交流讨论

更多正版甘特图软件下载、购买、授权咨询,请点这里!

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年9月13日
下一篇 2022年9月13日

相关推荐

发表回复

登录后才能评论