Display a project with it's child

Hi, I want to display only on the gantt a task and his children for example I have this structure of table (task.png) and I want to display the project 1 and child 1, I tried this attempt but it didn’t work and I didn’t have any error in the console.Thanks.

[code]@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/parc”, “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_sql(“select * from task where id=1 and id=2”,“id”, “start_date,duration,text,progress,sortorder,parent”);[/code]

Hi,
please clarify the scenario.
Do you store a several projects in a database that should be displayed separately (so the case is not limited by a project and it’s first-level childs) ?
If so, you need to add an additional column like project_id which will store id of the root item for each project. Then you’ll be able to select required ones using a simple WHERE condition

I want to display from the table which I posted , what’s the problem of this select:

gantt.render_sql("select * from task where id=1 and id=2","id", "start_date,duration,text,progress,sortorder,parent");

Hi,
the following condition will never match

WHERE  id=1 AND id=2 

Probably it should be following, record or can be either 1 or 2, not 1 and two at the same time

WHERE id=1 OR id=2

Sorry, I think you are not understand what I want, if I have project which it has many children, for example a project with 10 children, how can I display only the project and it’s children ?

Hi,
I believe that is what i’ve described in my first reply:)

You need to add an additional column e.g. ‘project_id’, which will store the id of a root task (‘parent’ stores only a direct parent, and can’t be used for this task).
Each time new task is created, you can assign a project id value to it. For example by using onTaskCreated event
docs.dhtmlx.com/gantt/api__gantt … event.html

When it’s done, you’ll be able selecting a separate project by a ‘project_id’ in a WHERE part of connector query