毕业设计管理系统之三gantt学习一部分知识整理
Gantt图文档
<!--[if !supportLists]-->1、 <!--[endif]-->gantt构造函数
var gantt = new GanttChart();
gantt.create(divID); divID是作为甘特图的父容器;
create方法应该在gantt属性设置之后调用;
示例代码:
2、GanttProjectInfo构造函数
var project1 = new GanttProjectInfo(id, name, startDate);
id:项目编号
name:项目名称
startDate:项目开始日期
注意:javascript 中日期对象月份是从0 开始的;示例代码是表示:2014年6月28号;
3、GanttTaskInfo构造函数
var parentTask1 = new GanttTaskInfo(id, name, EST, duration, predecessorTaskId);
id: 任务编号
name:任务名称
EST :计划任务开始时间
duration:任务工期(按天)
predecessorTaskId:前置任务编号
示例代码:
4、dhtmlxGantt API 方法
我们有两种类型对象:分别是设计时对象和运行时对象;
设计时对象(GanttProjectInfo, GanttTaskInfo ):在调用create方法之前初始化内容;
运行时对象(GanttChart, GanttProject, GanttTask):在调用create方法之后可以操作的对象。
4.1设计时对象API
GanttProjectInfo对象 |
|
addTask |
给项目增加特定的GanttTaskInfo对象 |
deleteTask |
从项目中删除对象 |
getTaskById |
根据编号返回GanttTaskInfo对象 |
GanttTaskInfo对象 |
|
addChildTask |
给GanttTaskInfo对象增加子任务 |
var parentTask1 = new GanttTaskInfo(1, "Old code review", new Date(2014, 5, 28), 29, "");
parentTask1.addChildTask(new GanttTaskInfo(2, "Convert to J#", new Date(2014, 6, 11), 12, ""));
var childTask2 = new GanttTaskInfo(3, "Hosted Control", new Date(2014,7, 7), 10, "1"); parentTask1.addChildTask(childTask2 );
|
4.2运行时对象API
4.2.1 GanttChart对象api
GanttChart对象 |
|
初始化方法 - create()方法之前调用 |
|
addProject |
给gantt增加GanttProjectInfo对象 |
attachEvent |
增加不同类型的事件处理 ganttChart.attachEvent(evName, evHandler); evName:事件名称,注意大小写敏感; evHandler:用户定义事件处理方法; onBeforeContextMenu: occurs when user clicks the mouse button on Tree items. onTaskClick : occurs when user clicks a Task item. onTaskStartDrag : occurs when user starts to drag a Task item. onTaskDragging : occurs while user is dragging a Task item. onTaskEndDrag : occurs when user finished to drag a Task item. onTaskStartResize : occurs when user starts to resize a Task item. onTaskResizing : occurs while user is resizing a Task item. onTaskEndResize : occurs when user finished to resize a Task item. |
create |
在页面上创建GanttChart对象 |
getMonthScaleLabel |
returns a string representation of current month for the month scale row; you may override this function to customize the label |
setContextMenu |
adds custom context menu of type dhtmlXMenuObject |
setEditable |
defines whether GanttChart is editable by user |
setImagePath |
sets path to image directory |
setMonthNames |
defines full month names for your locale |
setShortMonthNames |
defines short month names for your locale |
setStylePath |
set path to styles file, default is “codebase/style.css”; used in simple printing method printToWindow |
showContextMenu |
enables or disables default context menu in tree, which can be used for basic task manipulations |
showDescProject |
enables or disables inline project description (displayed right after the project bar), and configures the shown values |
showDescTask |
enables or disables inline task description (displayed right after the task bar), and configures the shown values |
showNewProject |
show/hide new project bar at start-up; it is useful if you have no project at all, and user needs some start point where the menu is attached |
showTooltip |
show/hide task & project tooltip (info panel) |
showTreePanel |
show/hide left side tree panel |
useShortMonthNames |
use short or full month name in the month label axis |
GanttChart对象 |
|
运行时方法 - create()方法之前调用 |
|
clearAll |
clears all control's contents |
deleteProject |
deletes project from chart by id |
getPrintableHTML |
returns chart in html format suitable for printing, full-sized and without scrollbars |
getProjectById |
returns GanttProject object by id |
getXML |
returns XML string representation of the chart content |
insertProject |
inserts new project with specified id, name, start date and returns it |
loadData |
loads XML data from string or file |
printToWindow |
opens chart full-sized in a new window, from where you can print it as you like |
saveData |
saves XML data to server using URL specified in setSavePath and encoding “application/x-www-form-urlencoded” |
setLoadPath |
sets URL which is used to load chart data with loadData method调用服务器端servlet来载入数据;loadData方法之前调用; |
setSavePath |
sets URL which is used to save chart data with saveData method:调用服务器端servlet来保存数据,saveDate方法之前调用; |
4.2.2 GanttProject对象api
GanttProject对象 |
|
isProject |
this is object property, equals true; used to distinguish Project and Task in menu event handler |
deleteTask |
deletes task from project by id |
getDuration |
calculates and returns the duration of project in hours |
getId |
returns id of project |
getName |
returns name of project |
getPercentCompleted |
calculates and returns percent completed of project |
getStartDate |
returns start date of project |
getTaskById |
returns GanttTask object by id |
insertTask |
inserts new task with specified id, name, start date, duration, percent completed, predecessor task Id, parent task Id and returns it |
setName |
sets name of this project |
setPercentCompleted |
sets percent completed for this project |
4.2.3 GanttTask对象api
GanttTask对象 |
|
isTask |
this is object property, equals true; used to distinguish Project and Task in menu event handler |
getDuration |
返回工期(用小时表示) |
getEST |
获取任务计划开始时间 |
getFinishDate |
计算返回任务完成时间 |
getId |
返回任务编号 |
getName |
返回任务名称 |
getParentTaskId |
返回父任务编号 |
getPercentCompleted |
获取任务完成比例 |
getPredecessorTaskId |
获取前置任务编号 |
setDuration |
设置任务工期 |
setEST |
设置任务计划开始时间 |
setName |
设置任务名称 |
setPercentCompleted |
设置任务完成百分比 |
setPredecessor |
设置前置任务 var task121 = project2.getTaskById(121); task121.setPredecessor(120);
// to remove the connection var task122 = project2.getTaskById(122); task122.setPredecessor(""); |
5、xml文件结构
<?xml version="1.0" encoding="UTF-8"?>
<projects>
<project id="1" name="project1" startdate="2006,12,14">
<task id="1">
<name>project1 task1</name>
<est>2006,12,14</est>
<duration>120</duration>
<percentcompleted>60</percentcompleted>
<predecessortasks></predecessortasks>
<childtasks>
<task id="2">
<name>project1 task2</name>
<est>2006,12,14</est>
<duration>100</duration>
<percentcompleted>20</percentcompleted>
<predecessortasks></predecessortasks>
<childtasks></childtasks>
</task>
<task id="6">
<name>project1 task6</name>
<est>2006,12,15</est>
<duration>90</duration>
<percentcompleted>10</percentcompleted>
<predecessortasks>2</predecessortasks>
<childtasks></childtasks>
</task>
</childtasks>
</task>
</project>
<project id="2" name="project2" startdate="2006,12,20">
<task id="12">
<name>project2 task12</name>
<est>2006,12,20</est>
<duration>140</duration>
<percentcompleted>60</percentcompleted>
<predecessortasks></predecessortasks>
<childtasks>
<task id="14">
<name>project2 task14</name>
<est>2006,12,20</est>
<duration>100</duration>
<percentcompleted>20</percentcompleted>
<predecessortasks></predecessortasks>
<childtasks></childtasks>
</task>
</childtasks>
</task>
</project>
</projects>
窗体顶端
窗体底端
<!--EndFragment-->