如何打开空甘特图?

时间:2015-04-29 14:52:07

标签: java html5 java-ee dhtmlx

在我的web java应用程序中,我需要创建许多项目,所以我需要每次都需要打开一个新的空甘特,问题是表任务包含其他项目,如果我想创建一个新项目,页面将显示所有旧任务,我能用这个技巧做些什么,请帮忙。 的index.html

  <form action="newgantt.html">
 <input type="submit" value="gantt" >
</form>

newgantt.html

<body>
<div id="gantt_here" style="width:100%; height:500px;"></div>
<script type="text/javascript">
           gantt.config.xml_date = "%Y-%m-%d %H:%i";
            gantt.config.scale_unit = "day";
            gantt.config.duration_unit = "day";
            gantt.config.date_scale = "%d"; 
    gantt.init("gantt_here");
    gantt.load("Conector");
     var dp = new  dataProcessor("Conector");
    dp.init(gantt);

Conector.java

@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
    Connection conn = null;
    try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");
    } catch (Throwable e) {
        e.printStackTrace();
    }
    JSONGanttConnector gantt = new JSONGanttConnector(conn, DBType.MySQL);
    gantt.servlet(req, res);
    gantt.mix("open", "1");
 gantt.enable_order("sortorder");
 gantt.render_links("gantt_links", "id", "source,target,type");
 gantt.render_table("tasks", "id","text", "start_date,duration,progress,sortorder");
 }

1 个答案:

答案 0 :(得分:0)

你只有一个对象“gantt”,是你的甘特的参考。如果你想创建一个新的甘特图,你需要销毁旧的甘特图并重新加载数据:

if(gantt)
{
   gantt.destructor();
}

或者像这样添加新的甘特图对象:

function init() {
    gantt1 = Gantt.getGanttInstance();
    gantt1.init("first");
    gantt1.parse(firstTask);

    gantt2 = Gantt.getGanttInstance();
    gantt2.init("second");
    gantt2.parse(secondTask);   
}


<body onload="init();">
    <div id="first" class="dhx_cal_container" ...>
        ...
    </div>
    <br>
    <div id="gantt_here_2" class="dhx_cal_container" ...>
        ...
    </div>  
</body>