Filtering single project from database

I’ve got a gantt chart that by default shows multiple nested projects and their corresponding tasks.

I’m trying to allow users to display a single project by sending an extra parameter to the data processor, which in my case is a CodeIgniter controller.

This sort of works, in that I’ve checked in Chrome’s developer console and the appropriate project/tasks are returned, but nothing is displayed on the gantt chart, presumably because the filtered project’s parent is not in the returned data.

Can anyone suggest a workaround for this?

if you use basic data scheme, each task stores ID of its direct parent. So in order to filter certain tasks by project, you’ll need to lookup the whole chain of parent tasks until the root task (which is the ‘project’) and check if id of that task(project) is equal the required project id.
So if you do filtering only by e.g. “WHERE task.parent_id = project_id” - it will give you only direct successors of the project task, without their children and the project task itself.

In order to ease the filtering, you can add some redundancy to the data scheme. For example, if you add a column ‘project_id’, which will hold the id of the top-most parent, you could do filtering very easy, just by “WHERE task.project_id = project_id”

In order to keep the task.project_id up to date, you can use following client side events … event.html … event.html