我从XML格式的MSSQL获取数据,即
<data><task id="1"><start_date>1906-10-04 00:00</start_date><duration>58</duration><text>Project #1</text><progress>0.6</progress><sortorder>0</sortorder><parent>0</parent></task><task id="2"><start_date>1906-10-05 00:00</start_date><duration>44</duration><text>fff</text><progress>0.7</progress><sortorder>1</sortorder><parent>1</parent></task><coll_options for="links"><item source="2" target="2" type="1"/><item source="3" target="2" type="1"/></coll_options></data>
我不知道如何在dhtmlxgantt中使用所以如果有人能告诉我怎么做我的gantt,html代码是
<!DOCTYPE html>
<style type="text/css" media="screen">
html, body{
margin:10px;
padding:0px;
height:100%;
overflow:hidden;
}
</style>
<head>
<title>How to Start with dhtmlxGantt</title>
<script src="codebase/dhtmlxgantt.js"></script>
<link href="codebase/dhtmlxgantt.css" rel="stylesheet">
</head>
<body>
<div id="gantt_here" style='width:1000px; height:400px;'></div>
<script type="text/javascript">
var tasks = {
data:[
{id:1, text:"Project #1",start_date:"01-04-2013", duration:11,
progress: 0.6, open: true},
{id:2, text:"DEEPAK", start_date:"03-04-2013", duration:5,
progress: 1, open: true, parent:1},
{id:3, text:"Task #2", start_date:"02-04-2013", duration:7,
progress: 0.5, open: true, parent:1},
{id:4, text:"Task #2.1", start_date:"03-04-2013", duration:2,
progress: 1, open: true, parent:3},
{id:5, text:"Task #2.2", start_date:"04-04-2013", duration:3,
progress: 0.8, open: true, parent:3},
{id:6, text:"Task #2.3", start_date:"05-04-2013", duration:4,
progress: 0.2, open: true, parent:3}
],
links:[
{id:1, source:1, target:2, type:"1"},
{id:2, source:1, target:3, type:"1"},
{id:3, source:3, target:4, type:"1"},
{id:4, source:4, target:5, type:"0"},
{id:5, source:5, target:6, type:"0"}
]
};
gantt.config.xml_date = "%Y-%m-%d %H:%i";
gantt.init("gantt_here");
gantt.parse(tasks);
var dp=new dataProcessor("data.php");
dp.init(gantt);
</script>
</body>
</html>
这是我为dhtmlxgantt输入的HTML代码,如果有人能告诉我如何在dhtmlxgantt中使用此数据。这会很有帮助的。提前感谢您尝试过这个dhtmlxgantt API (https://docs.dhtmlx.com/gantt/api__gantt_xml_other.html)吗?我相信这个api将允许你解析/序列化xml格式的数据。