跳到主要内容

模板控件

一个包含一些 HTML 内容的容器。

template_control

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;
});

模板控件

初始化

要将 template 控件添加到 lightbox,请按以下步骤操作:

  1. 向 lightbox 配置中添加一个段:
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"}
];
  1. 为该段设置标签:
gantt.locale.labels.section_template = "Details";
  1. 通过某个事件设置控件的内容,例如 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 控件中通常较为重要且常被设置(完整列表请参见 这里):

  • name - (string) 段名称
  • height - (number) 段高度
  • map_to - (string) 将映射到该段的数据属性的名称
  • type - (string) [section control] 的类型(参见 guides/default-edit-form.md#lightboxcontrols)
  • focus - (boolean) 如果设置为 true,打开 lightbox 时该段将获得焦点
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.