翻譯|使用教程|編輯:秦林|2022-11-15 11:15:55.133|閱讀 377 次
概述:本文給大家講解在使用DHTMLX Gantt時,如何使用燈箱元素,歡迎大家下載最新版試用體驗。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文給大家講解在使用DHTMLX Gantt時,如何使用燈箱元素,歡迎大家下載最新版試用體驗。
要獲取/設置燈箱控件的值,請使用getLightboxSection方法,如下所示:
//to get the value var value = gantt.getLightboxSection('description').getValue(); //to set the value gantt.getLightboxSection('description').setValue('abc');
要檢查燈箱當前是打開還是關閉,請使用getState方法返回的狀態對象的燈箱屬性。如果燈箱打開 - 該方法將返回打開的任務的 ID,否則為“null”或“undefined”
if (gantt.getState().lightbox){ //the code for the opened lighbox } else { //the code for the closed lighbox }
要將數據屬性映射到燈箱部分,請使用部分對象的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"} ];
要設置燈箱部分的默認值,請使用該部分對象的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 歡迎進群交流討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn