Hi,
I am pretty new to dhtmlx and the java connector and I have been following the initialization tutorial https://docs.dhtmlx.com/connector__java__init.html
However when I try to do gantt.load(“BasicConnector.java”), it seems to try to parse it as json. I have included my code below:
<div id="gantt_here"
style='width: 100%; height: 650px; position: relative;'></div>
<script type="text/javascript">
function createBox(sizes, class_name) {
var box = document.createElement('div');
box.style.cssText = [ "height:" + sizes.height + "px",
"line-height:" + sizes.height + "px",
"width:" + sizes.width + "px", "top:" + sizes.top + 'px',
"left:" + sizes.left + "px", "position:absolute" ]
.join(";");
box.className = class_name;
return box;
}
gantt.templates.grid_row_class = gantt.templates.task_class = function(
start, end, task) {
var css = [];
if (gantt.hasChild(task.id)) {
css.push("task-parent");
}
if (!task.$open && gantt.hasChild(task.id)) {
css.push("task-collapsed");
}
return css.join(" ");
};
gantt.config.fit_tasks = true;
gantt.init("gantt_here");
gantt.load("BasicConnector.java");
And this is the connector:
public class BasicConnector extends ConnectorServlet {
@Override
protected void configure() {
// obtain DB connection
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/gantt", "test", "test");
}
catch (Throwable e) {
e.printStackTrace();
}
// Initializes connector
GridConnector gantt = new GridConnector(conn, DBType.MySQL);
// configures the used table and fields
gantt.render_table("gantt_tasks", "id", "start_date,duration,text,progress,parent");
}
}
Thank you!