翻譯|使用教程|編輯:秦林|2022-10-11 11:21:56.313|閱讀 156 次
概述:這篇文章給大家講解利用dhtmlxGantt導入MS項目。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
這篇文章給大家講解利用dhtmlxGantt導入MS項目。
導入MS項目
為了轉換XML或MPP MS項目文件,您需要向導出服務發送以下請求:
請求參數為:
<form action="http://export.dhtmlx.com/gantt" method="POST" enctype="multipart/form-data"> <input type="file" name="file" /> <input type="hidden" name="type" value="msproject-parse"> <button type="submit">Get</button> </form>
或者,您可以使用 客戶端API ,如下所示:
gantt.importFromMSProject({ data: file, taskProperties: ["Notes", "Name"], callback: function (project) { if (project) { gantt.clearAll(); if (project.config.duration_unit) { gantt.config.duration_unit = project.config.duration_unit; } gantt.parse(project.data); } } });
響應將包含以下結構的 JSON:
{ data: {}, config: {}, resources: [], worktime: {} }
設置持續時間單位
要設置預期的持續時間單位,也可以將 durationUnit (“分鐘”、“小時”、“天”、“周”、“月”、“年”)字符串發送到服務器。
<form action="http://export.dhtmlx.com/gantt" method="POST" enctype="multipart/form-data"> <input type="file" name="file" /> <input type="hidden" name="type" value="msproject-parse"> <input type="hidden" name="data" value="{ \"durationUnit\": \"hour\" }" /> <button type="submit">Get</button> </form>
或者設置以下格式:
gantt.importFromMSProject({ data: file, durationUnit: "hour", callback: function(project){} });
獲取項目屬性
要獲取項目字段,可以將帶有一組必要字段的projectProperties輸入發送到服務器。它提取項目實體的任意屬性進入輸出的配置屬性。 這是支持的屬性列表。
projectProperties - 指定應放入響應中的項目屬性數組。
<form action="http://export.dhtmlx.com/gantt" method="POST" enctype="multipart/form-data"> <input type="file" name="file" /> <input type="hidden" name="type" value="msproject-parse"> <input type="hidden" name="data" value="{ \"projectProperties\": [\"Author\", \"Title\"] }" /> <button type="submit">Get</button> </form>
或者設置以下格式:
gantt.importFromMSProject({ data: file, durationUnit: "hour", projectProperties: ["Author", "Title"], callback: function(project){ var config = project.config; alert(config.$custom_properties.Author); } });
獲取任務屬性
要獲取任務字段, taskProperties可以將帶有一系列必要字段 輸入發送到服務器。 它提取任務實體的任意屬性。 以下是支持的屬性列表:
taskProperties - 指定要導入的附加任務屬性數組。
<form action="http://export.dhtmlx.com/gantt" method="POST" enctype="multipart/form-data"> <input type="file" name="file" /> <input type="hidden" name="type" value="msproject-parse"> <input type="hidden" name="data" value="{ \"taskProperties\": [\"Contact\", \"Priority\"] }" /> <button type="submit">Get</button> </form>
或者設置以下格式:
gantt.importFromMSProject({ data: file, durationUnit: "hour", taskProperties: ["Contact", "Priority"], callback: function(project){ var config = project.config; alert(config.$custom_properties.Author); gantt.parse(project.data); } }); gantt.attachEvent("onTaskLoading", function(task) { if (task.$custom_data) { task.contact = task.$custom_data["Contact"]; task.priority = task.$custom_data["priority"]; delete task.$custom_data; } return true; });
dhtmlxGantt是用于跨瀏覽器和跨平臺應用程序的功能齊全的Gantt圖表,可滿足項目管理控件應用程序的所有需求,是最完善的甘特圖圖表庫。了解更多DhtmlxGantt相關內容和資訊,歡迎在線咨詢或者私信我獲取正版試用版及報價。
甘特圖控件交流群:764148812 歡迎進群交流討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn