Adding child task to another task from within the gantt grid

6 posts, 0 answers
  1. Abhilash
    Abhilash avatar
    8 posts
    Member since:
    Jan 2014

    Posted 28 May 2015 Link to this post

    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.

  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 01 Jun 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Abhilash
    Abhilash avatar
    8 posts
    Member since:
    Jan 2014

    Posted 29 Jun 2015 in reply to Dimitar Terziev Link to this post

    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

     

  5. Abhilash
    Abhilash avatar
    8 posts
    Member since:
    Jan 2014

    Posted 29 Jun 2015 in reply to Abhilash Link to this post

    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.

  6. Abhilash
    Abhilash avatar
    8 posts
    Member since:
    Jan 2014

    Posted 29 Jun 2015 in reply to Abhilash Link to this post

    Attaching the calculation method
  7. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 30 Jun 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready