This is a migrated thread and some comments may be shown as answers.
Adding child task to another task from within the gantt grid
5 Answers 84 Views
This is a migrated thread and some comments may be shown as answers.
Abhilash
Top achievements
Rank 1
Abhilash asked on 28 May 2015, 02:28 PM

Hi, 

Following is my requirement 

1. On load the Gantt is initialized with a default set of tasks called activities 

2. each activity can have one or more child tasks 

3. The child task is added using a Add Task button just below the activity 

4. on click of Add task a new task is added as child to the activity preceeding the Add Task button/link row

 

I am able to achieve 1 & 3 from a UI perspective .The Add Task row is also a task which is restyled/ retemplated on databound based on a custom task type to remove other task related information and just show an add task link.

I am able to catch the event on add task click and also get the id of the row/task but i am not able to add a new task as a child programatically to the  activity above These are bits of code i have tried.

 

function addTask(adderButtonRowId) {
    var gantt = $("#gantt").data("kendoGantt");
    var task = getNewTask(adderButtonRowId);
    var taskNew = new kendo.data.GanttTask(task);
    gantt.dataSource.add(taskNew);
}

After executing this however the UI is not rendered as expected. The getNewTask method returns a task object with attributes such as parentId, orderId and id set appropriately internally so that the new task is child of the preceeding activity and in proper order. 

 

Please let know what am i missing, Any help appreciated.Thanks in advance.

 
 

I am able to achieve 1 & 3 from a UI perspective

the Add Task row is also a task which is restyled/ retemplated on databound based on a custom task type to remove other task related information and just show an add task link

 I am able to catch the add task click and also get the id of the row but i am not able to add a new task as a child programatically to the above activity

 

These are bits of code i have tried

 

function addTask(adderButtonRowId) {
    var gantt = $("#gantt").data("kendoGantt");
    var task = getNewTask(adderButtonRowId);
    var taskNew = new kendo.data.GanttTask(task);
    gantt.dataSource.add(taskNew);
}

 

 

However the UI is not rendered as expected. The getNewTask

 method returns a task object with attributes such as parentId, orderId and id set appropriately.

 

Any help appreciated.

Thanks in advance.

I am able to achieve 1 & 3 from a UI perspective

the Add Task row is also a task which is restyled/ retemplated on databound based on a custom task type to remove other task related information and just show an add task link

 I am able to catch the add task click and also get the id of the row but i am not able to add a new task as a child programatically to the above activity

 

These are bits of code i have tried

 

function addTask(adderButtonRowId) {
    var gantt = $("#gantt").data("kendoGantt");
    var task = getNewTask(adderButtonRowId);
    var taskNew = new kendo.data.GanttTask(task);
    gantt.dataSource.add(taskNew);
}

 

 

However the UI is not rendered as expected. The getNewTask

 method returns a task object with attributes such as parentId, orderId and id set appropriately.

 

Any help appreciated.

Thanks in advance.

I am able to achieve 1 & 3 from a UI perspective

the Add Task row is also a task which is restyled/ retemplated on databound based on a custom task type to remove other task related information and just show an add task link

 I am able to catch the add task click and also get the id of the row but i am not able to add a new task as a child programatically to the above activity

 

These are bits of code i have tried

 

function addTask(adderButtonRowId) {
    var gantt = $("#gantt").data("kendoGantt");
    var task = getNewTask(adderButtonRowId);
    var taskNew = new kendo.data.GanttTask(task);
    gantt.dataSource.add(taskNew);
}

 

 

However the UI is not rendered as expected. The getNewTask

 method returns a task object with attributes such as parentId, orderId and id set appropriately.

 

Any help appreciated.

Thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 01 Jun 2015, 06:23 AM
Hi,

Could you provide a dojo snippet with the exact implementation that you are using so we could inspect it locally?

I have prepared a dojo snippet showing how to add task through the gantt's API. If there is a selection the "Add Task with Api" button will add a child task to the current selected one, otherwise it will add a root task.

Regards,
Dimitar Terziev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Abhilash
Top achievements
Rank 1
answered on 29 Jun 2015, 07:22 AM

Hi,

 I was able to achieve the above functionality as shown in the dojo snippet, however if you observe the delete functionality is behaving in a strange manner, adding a new task can be done using the task adder row. to remove a task, select the task right click and click delete in the context menu.

 The problem is deleting a task changes the order of an activities children in an arbitrary manner and breaks the expected behavior which is the children should be sorted by their order with the last row being the task adder for the activity.

 

For instance - add two new tasks under activity 1 by clicking the Task Adder row for activity 1 twice and the try removing the New Task3, after which the Task Adder row is no longer the last child of Activity 1 row

 

0
Abhilash
Top achievements
Rank 1
answered on 29 Jun 2015, 01:11 PM

Another thing we are trying out with the Gantt is a time weighted average calculation of percentComplete at the Activity level,

 Something similar to the attached example

 But it seems the current percentComplete seems to be depicted by the formula activity% = (task1 % + task2 % + .... + taskn %/ n) is there a way to override this calculation mechanism.

0
Abhilash
Top achievements
Rank 1
answered on 29 Jun 2015, 01:12 PM
Attaching the calculation method
0
Dimitar Terziev
Telerik team
answered on 30 Jun 2015, 02:36 PM
Hi,

The reason for the experienced behavior when a task is removed is caused by the fact that the gantt widget expects that the orderId is zero based, while in the dojo snippet provided it is starting from 1.

As for your second query, there is no option to change how the percent complete for the summary tasks is calculated. 

Regards,
Dimitar Terziev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Gantt
Asked by
Abhilash
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Abhilash
Top achievements
Rank 1
Share this question
or