翻譯|使用教程|編輯:秦林|2022-10-17 15:57:00.707|閱讀 292 次
概述:這篇文章給大家講解dhtmlxGantt編輯器的類型。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
這篇文章給大家講解dhtmlxGantt編輯器的類型。
1、編輯器類型
內聯編輯器存儲在editor_types配置對象中。
有幾個預定義的內聯編輯器:
var editors = { text: {type: "text", map_to: "text"}, start_date: {type: "date", map_to: "start_date", min: new Date(2018, 0, 1), max: new Date(2019, 0, 1)}, end_date: {type: "date", map_to: "end_date", min: new Date(2018, 0, 1), max: new Date(2019, 0, 1)}, duration: {type: "number", map_to: "duration", min:0, max: 100}, priority: {type:"select", map_to:"priority", options:gantt.serverList("priority")}, predecessors: {type: "predecessor", map_to: "auto"} };
2、日期編輯器中的日期限制
從 v6.3 開始,日期內聯編輯器的最小和最大輸入值沒有默認限制。
如果您希望時間刻度上可見的日期限制日期內聯編輯器的最小值和最大值(除非提供自定義最小值/最大值),您可以指定動態最小值/最大值:
const dateEditor = {type: "date", map_to: "start_date", min: function(taskId){ return gantt.getState().min_date }, max: function( taskId ){ return gantt.getState().max_date } };
3、包含結束日期的編輯器
如果您正在使用任務的包含結束日期的格式并希望使其與網格中的內聯編輯正常工作,則必須創建一個特殊的編輯器來編輯任務的包含結束日期,如下所示:
// inclusive editor for end dates // use the default editor, but override the set_value/get_value methods var dateEditor = gantt.config.editor_types.date; gantt.config.editor_types.end_date = gantt.mixin({ set_value: function(value, id, column, node){ var correctedValue = gantt.date.add(value, -1, "day"); return dateEditor.set_value.apply(this, [correctedValue, id, column, node]); }, get_value: function(id, column, node) { var selectedValue = dateEditor.get_value.apply(this, [id, column, node]); return gantt.date.add(selectedValue, 1, "day"); }, }, dateEditor); var textEditor = {type: "text", map_to: "text"}; var startDateEditor = {type: "date", map_to: "start_date"}; var endDateEditor = {type: "end_date", map_to: "end_date"}; var durationEditor = {type: "number", map_to: "duration", min:0, max: 100}; gantt.config.columns = [ {name: "text", label: "Name", tree: true, width: 200, editor: textEditor, resize: true}, {name: "duration", label: "Duration", width:80, align: "center", editor: durationEditor, resize: true}, {name: "start_date", label: "Start", width:140, align: "center", editor: startDateEditor, resize: true}, {name: "end_date", label: "Finish", width:140, align: "center", editor: endDateEditor, resize: true} ]; // change lightbox and grid templates to display dates of tasks in an inclusive format gantt.templates.task_end_date = function(date){ return gantt.templates.task_date(new Date(date.valueOf() - 1)); }; var gridDateToStr = gantt.date.date_to_str("%Y-%m-%d"); gantt.templates.grid_date_format = function(date, column){ if(column === "end_date"){ return gridDateToStr(new Date(date.valueOf() - 1)); }else{ return gridDateToStr(date); } }
dhtmlxGantt是用于跨瀏覽器和跨平臺應用程序的功能齊全的Gantt圖表,可滿足項目管理控件應用程序的所有需求,是最完善的甘特圖圖表庫。了解更多DhtmlxGantt相關內容和資訊,歡迎在線咨詢或者私信我獲取正版試用版及報價。
甘特圖控件交流群:764148812 歡迎進群交流討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn