suivi-dhx-trial-gantt
Version:
An open source JavaScript Gantt chart that helps you illustrate a project schedule in a nice-looking chart.
69 lines (64 loc) • 1.79 kB
HTML
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>ReInit in different container</title>
<script src="../../codebase/dhtmlxgantt.js?v=9.0.5"></script>
<link rel="stylesheet" href="../../codebase/dhtmlxgantt.css?v=9.0.5">
<link rel="stylesheet" href="../common/controls_styles.css?v=9.0.5">
<style>
html,
body {
width: 100%;
height: 100%;
margin: unset;
padding: 0;
box-sizing: border-box;
}
body {
/* Enables Flexbox */
display: flex;
/* Stacks children vertically */
flex-direction: column;
}
.gantt-control {
/* Takes up space as per its content */
}
.gantt-container {
/* Each element will grow to the same size */
flex: 1;
/* Adds scroll if content overflows */
overflow: auto;
}
</style>
</head>
<body>
<div id="gantt_here" class="gantt-container"></div>
<div class="gantt_control">
<input type="button" value="Init in another html container" onclick="reinit()">
</div>
<div id="gantt_here2" class="gantt-container"></div>
<script>
gantt.init("gantt_here");
gantt.parse({
data: [
{ id: 1, text: "Project #2", start_date: "01-04-2023", duration: 18, progress: 0.4, open: true },
{ id: 2, text: "Task #1", start_date: "02-04-2023", duration: 8, progress: 0.6, parent: 1 },
{ id: 3, text: "Task #2", start_date: "11-04-2023", duration: 8, progress: 0.6, parent: 1 }
],
links: [
{ id: 1, source: 1, target: 2, type: "1" },
{ id: 2, source: 2, target: 3, type: "0" }
]
});
let currentContainer = "gantt_here";
function reinit() {
if (currentContainer === "gantt_here") {
currentContainer = "gantt_here2";
}
else {
currentContainer = "gantt_here";
}
gantt.init(currentContainer);
}
</script>
</body>