赞
踩
gantt.plugins({
tooltip: true,
quick_info: true,// 快速信息框
// multiselect: true,// 激活多任务选择
});
gantt.config.tooltip_offset_x = 10;
gantt.config.tooltip_offset_y = 30;
gantt.config.open_split_tasks = true;
gantt.config.details_on_create = true;
gantt.config.autofit = true;
gantt.config.resize_rows = true;
gantt.config.open_tree_initially = true;
gantt.config.order_branch = true;
gantt.config.order_branch_free = true;
gantt.config.placeholder_task = true;
gantt.config.preserve_scroll = true;
gantt.config.round_dnd_dates = true;
gantt.config.scale_height = 50;
gantt.config.show_links = true;
gantt.config.sort = true;
gantt.plugins({
tooltip: true,
quick_info: true,// 快速信息框
});
gantt.config.show_quick_info = true;
gantt.config.sort = true;
gantt.config.row_height = 44;
gantt.config.drag_project = true;
gantt.config.scale_height = 40;
gantt.config.start_date = new Date(`${new Date().getFullYear()-2},${new Date().getMonth()},${new Date().getDay()}`)
gantt.config.end_date = new Date(`${new Date().getFullYear()+2},${new Date().getMonth()},${new Date().getDay()}`)
gantt.config.show_tasks_outside_timescale = true
gantt.config.scales = [
{ unit: "year", step: 1, format: "%Y" },
{ unit: "month", step: 1, format: "%M" },
];
(用户可自定义任务内部显示内容)
gantt.templates.task_text = function (start, end, task) {
return `
<span style="margin-left:10px;color:white;">${task.text}</span>
`;
};
gantt.templates.lightbox_header = function (start_date, end_date, task) {
return `<b>${task.text}</b>`
};
(此处除了 description 与 time 为gantt内置弹出框元素其余为自定义元素)
【自定义元素详细配置方法在另外一篇文章解释】
gantt.config.lightbox.sections = [ { name: "description", height: 36, map_to: "text", type: "textarea", focus: true, }, { name: "time", type: "duration", map_to: "auto" }, { name: "Participants", height: 36, map_to: "Participants", type: "ParticipantsPlan", focus: true, }, { name: "BgColor", height: 36, map_to: "color", type: "ParticipantsPlanColor", focus: true, }, ];
// 配置任务灯箱
gantt.config.lightbox.project_sections= [
{name: "description", height: 70, map_to: "text", type: "textarea", focus: true},
{name: "type", type: "typeselect", map_to: "type"},
{name: "time", type: "duration", readonly: true, map_to: "auto"}
];
// 配置里程碑灯箱
gantt.config.lightbox.milestone_sections= [
{name: "description", height: 70, map_to: "text", type: "textarea", focus: true},
{name: "type", type: "typeselect", map_to: "type"},
{name: "time", type: "duration", single_date: true, map_to: "auto"}
];
gantt.templates.grid_row_class = function (start, end, task) {
console.log("网格class", start, end, task);
};
gantt.templates.date_grid = function(date, task, column){
console.log('日期网格',date,task,column)
if(task && gantt.isUnscheduled(task) && gantt.config.show_unscheduled){
return gantt.templates.task_unscheduled_time(task);
}else{
return gantt.templates.grid_date_format(date);
}
}
gantt.templates.grid_indent = function(item){
return '<div class="gantt_tree_indent" style="display:none"></div>'
}
【自定义元素详细配置方法在另外一篇文章解释】
gantt.config.columns=[
{name:"text", label:"Task name", tree:true, width:'*' },
{name:"start_date", label:"Start time", align: "center" },
{name:"duration", label:"Duration", align: "center" },
{name:"add", label:"" }
];
gantt.templates.task_date= function(date){
return gantt.date.date_to_str(gantt.config.task_date)(date);
};
【 此功能属于扩展功能需单独配置 】
?gantt.plugins({tooltip: true});
gantt.templates.tooltip_text = function (start, end, task) {
return (
"<b>标题:</b> " +
task.text +
"<br/><span>开始:</span> " +
gantt.templates.tooltip_date_format(start) +
"<br/><span>结束:</span> " +
gantt.templates.tooltip_date_format(end) +
"<br/><span>进度:</span> " +
Math.round(task.progress * 100) +
"%"
);
};
【 return true 的含义是执行,默认即可 ,如果需要自定义 return fasle。便不会执行内置方法】
gantt.attachEvent("onTaskDblClick", function (id, e) {return true})
gantt.attachEvent("onAfterTaskAdd",function(id,item){return true})
gantt.attachEvent("onTaskSelected",function(id){return true})
gantt.attachEvent("onMouseMove",function(id,e){})
gantt.attachEvent("onAfterTaskDrag",function(id,mode,e){return true})
gantt.attachEvent("onTaskCreated",function(task){return true})
gantt.attachEvent("onBeforeLightbox",function(id){return true})
gantt.templates.progress_text = function (start, end, task) {
return Math.round(task.progress * 100) + "%";
};
gantt.templates.drag_link = function (from, from_start, to, to_start) {
console.log("拉杆from", from, from_start, to, to_start);
// return text;
};
gantt.templates.drag_link_class = function (from,from_start,to,to_start ) {
console.log("from", from, from_start, to, to_start);
};
以上是项目中所用到的部分方法,详细内容可查看官方文档。
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。