翻譯|使用教程|編輯:秦林|2022-11-09 09:41:15.437|閱讀 293 次
概述:本文給大家講解DHTMLX Gantt如何對控件選擇性控制,歡迎大家下載最新版試用體驗。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文給大家講解DHTMLX Gantt如何對控件選擇性控制,歡迎大家下載最新版試用體驗。
下拉列表框如下所示:
gantt.config.lightbox.sections = [ {name:"description", height:38, map_to:"text", type:"textarea", focus:true}, {name:"priority", height:22, map_to:"priority", type:"select", options: [ {key:1, label: "High"}, {key:2, label: "Normal"}, {key:3, label: "Low"} ]}, {name:"time", height:72, type:"duration", map_to:"auto"} ]; gantt.locale.labels.section_priority = "Priority";
要將選擇控件添加到燈箱,請執行以下步驟:
1、在燈箱配置中添加一個部分:
var opts = [ {key:1, label: "High"}, {key:2, label: "Normal"}, {key:3, label: "Low"} ]; gantt.config.lightbox.sections = [ {name:"description", height:38, map_to:"text", type:"textarea",focus:true}, {name:"priority", height:22, map_to:"priority",type:"select",options:opts}, {name:"time", height:72, type:"duration", map_to:"auto"} ];
2、給部分設置標簽:
gantt.locale.labels.section_priority = "Priority";
以下屬性最重要且通常用的時間控屬性:
以下屬性最重要且通常為選擇控件設置:
name - (字符串) 部分名稱
高度- (數字)截面高度
map_to - ( string ) 將被映射到該部分的數據屬性的名稱
type - ( string )部分控件的類型
focus - ( boolean ) 如果設置為true,該部分將專注于打開燈箱
options - ( array ) 對象數組。定義控件的選擇選項(用于選擇、復選框 和單選 控件)。數組中的每個對象都指定一個選項并具有以下屬性:
key - ( string ) 選項 id。此屬性與任務數據屬性進行比較以將選項分配給任務
label - ( string ) 選項標簽
default_value - ( any ) 該部分控件的默認值。僅在輸入值不足時應用
onchange - ( function ) 為該部分的控件指定“onChange”事件處理函數
通常,要為選擇控件設置值,請使用options參數:
gantt.config.lightbox.sections = [ { name:"priority",height:22, map_to:"priority",type:"select", options: [ {key:1, label: "High"}, {key:2, label: "Normal"}, {key:3, label: "Low"} ]} ];
options參數中的項目有 2 個強制屬性:
要從服務器填充控件,請將options選項設置為serverList方法返回的值:
gantt.config.lightbox.sections = [ {name:"description", ...}, { name:"priority",map_to:"priority",type:"select", options:gantt.serverList("priority")}, {name:"category", map_to:"category", type:"select", options:gantt.serverList("category")}, {name:"time", ...} ]; gantt.init("gantt_here"); gantt.load("/data");
/data url的輸出如下:
{ "tasks":[ {"id":1,"text":"Project #2","start_date":"01-04-2020","duration":18,"parent":0}, {"id":2,"text":"Task #1","start_date":"02-04-2020","duration":8,"parent":1}, {"id":3,"text":"Task #2","start_date":"11-04-2020","duration":8,"parent":1} ], "links":[ {"id":1,"source":1,"target":2,"type":"1"}, {"id":2,"source":2,"target":3,"type":"0"} ], "collections": { "priority":[ {"value":"1","label":"Low"}, {"value":"2","label":"Medium"}, {"value":"3","label":"High"} ], "category":[ {"value":"1","label":"Simple"}, {"value":"2","label":"Complex"}, {"value":"3","label":"Unknown"} ] } }
通過 dhtmlxConnector 加載選項,以下是dhtmlxConnector初始化的示例:
//data.php <?php include('connector-php/codebase/gantt_connector.php'); $res = new PDO("mysql:host=localhost;dbname=gantt", "root", ""); $list = new OptionsConnector($res); $list->render_table("priorities","id","id(value),name(label)"); $gantt = new JSONGanttConnector($res); $gantt->set_options("priority", $list); $gantt->render_links("gantt_links","id","source_task(source), target_task(target),type"); $gantt->render_table("gantt_tasks","id","start_date,duration,text,progress, sortorder,parent"); ?>
DHTMLX Gantt享有超十年聲譽,支持跨瀏覽器和跨平臺,性價比高,可滿足項目管理控件應用的所有需求,是最完善的甘特圖圖表庫?;鄱?022年終狂歡火熱進行中,知名軟控件產品享超低折扣,滿額豪禮贈,復購雙重大禮!了解更多內容,歡迎在線咨詢或者私信我獲取正版試用版及報價。
甘特圖控件交流群:764148812 歡迎進群交流討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn