这是一个用于容纳部分 HTML 内容的容器。
gantt.config.lightbox.sections = [
{name:"description", height:38, map_to:"text", type:"textarea", focus:true},
{name:"template", height:16, type:"template", map_to:"my_template"}, {name:"time", height:72, type:"duration", map_to:"auto"}
];
gantt.locale.labels.section_template = "Details";
gantt.attachEvent("onBeforeLightbox", function(id) {
var task = gantt.getTask(id);
task.my_template = "<span id='title1'>Holders: </span>"+ task.users
+"<span id='title2'>Progress: </span>"+ task.progress*100 +" %";
return true;
});
Related sample: Template control
要在 lightbox 中包含 template 控件,需要完成以下步骤:
1) 在 lightbox 配置中添加一个 section:
gantt.config.lightbox.sections = [
{name:"description", height:38, map_to:"text", type:"textarea", focus:true},
{name:"template", height:16, type:"template", map_to:"my_template"}, {name:"time", height:72, type:"duration", map_to:"auto"}
];
2) 为该 section 定义一个标签:
gantt.locale.labels.section_template = "Details";
3) 通过事件(如 onBeforeLightbox 事件)为控件填充内容:
gantt.attachEvent("onBeforeLightbox", function(id) {
var task = gantt.getTask(id);
task.my_template = "<span id='title1'>Holders: </span>"+ task.users
+"<span id='title2'>Progress: </span>"+ task.progress*100 +" %";
return true;
});
以下是 template 控件常用的一些属性(完整列表请参见 这里):