1、获取/设置控制值
要获取/设置灯箱控件的值,请使用getLightboxSection方法,如下所示:
//to get the valuevar value = gantt.getLightboxSection('description').getValue();//to set the valuegantt.getLightboxSection('description').setValue('abc');
2、检查灯箱是否打开
要检查灯箱当前是打开还是关闭,请使用getState方法返回的状态对象的灯箱属性。如果灯箱打开 – 该方法将返回打开的任务的 ID,否则为“null”或“undefined”
if (gantt.getState().lightbox){ //the code for the opened lighbox} else { //the code for the closed lighbox}
3、将数据属性映射到灯箱
要将数据属性映射到灯箱部分,请使用部分对象的map_to属性:
//assigns the "holders" section to a data property with the name "holder"gantt.config.lightbox.sections = [ {name:"description",height:38, type:"textarea", map_to:"text", focus:true}, {name:"holders", height:22, type:"textarea", map_to:"holder"}, {name:"time", height:72, type:"duration", map_to:"auto"}];
4、设置灯箱控件的默认值
要设置灯箱部分的默认值,请使用该部分对象的default_value属性。
例如,您已将自定义部分添加到灯箱 – “优先级” – 显示任务优先级。当用户创建新事件时,该字段将为空。要更正此类行为并默认设置,例如低优先级,请按以下方式指定灯箱:
var opts = [ { key:1, label: "High" }, { key:2, label: "Normal" }, { key:3, label: "Low" } ];gantt.config.lightbox.sections = [ {name:"description", height:38, type:"textarea", map_to:"text", focus:true}, {name:"priority", height:22, type:"select", map_to:"priority", options:opts, default_value:3}, {name:"time", height:72, type:"duration", map_to:"auto"}];
注:default_value属性设置灯箱部分的默认值,而不是新事件的默认值,即新事件只有在用户打开灯箱并保存事件后才会获得指定值。
要直接为新事件设置默认值,请使用onTaskCreated事件:
gantt.attachEvent("onTaskCreated", function(id, task){ task.priority = "Low"; return true;});
DHTMLX Gantt享有超十年声誉,支持跨浏览器和跨平台,性价比高,可满足项目管理控件应用的所有需求,是最完善的甘特图图表库。2022年终狂欢火热进行中,知名软控件产品享超低折扣,满额豪礼赠,复购双重大礼!了解更多内容,欢迎在线咨询或者私信我获取正版试用版及 价。
甘特图控件交流群:764148812 欢迎进群交流讨论
年终狂欢季,全场产品,限时特惠,立即了解详情!
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!