Gantt Custom Task List

1 Answer 152 Views
Gantt
Jerry
Top achievements
Rank 2
Iron
Iron
Jerry asked on 21 Jun 2022, 03:54 PM
How can I pop up a custom list of available tasks that a user is allowed to add to the gantt chart.  Preferably a different list depending on the level they are adding the child to.  Any examples of this concept would be great!

1 Answer, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 28 Jun 2022, 12:52 PM

Hello Jerry,

For convenience and better visibility from the community, I am sharing the answer from the related support thread:

You can reuse the demo's code to create a custom toolbar button where you can find the selected task and show your custom popup:

Here is a modification of the handler code that accesses the selected task and the level of the task:

<script>
    function findTaskByUid(gantt, uid) {
        for (var i = 0; i < gantt.get_allTasks().length; i++) {
            var task = gantt.get_allTasks()[i];
            if (task._uid == uid) {
                return task;
            }
        }
    }
    function findTaskByID(gantt, id) {
        for (var i = 0; i < gantt.get_allTasks().length; i++) {
            var task = gantt.get_allTasks()[i];
            if (task.get_id() == id) {
                return task;
            }
        }
    }

    function toolbar_click(button, ev) {
        var gantt = $telerik.$(button).closest(".RadGantt")[0].control;
        var tasksInProgressCount = 0;
        var selectedRow = gantt.get_kendoWidget().select();

        var selectedTaskUid = selectedRow.attr("data-uid");
        var task = findTaskByUid(gantt, selectedTaskUid);
        if (task) {
            var level = 0;
            var parentTask;
            while (task.get_parentId()) {
                task = findTaskByID(gantt, task.get_parentId())
                level++;
            }
            alert("task level: " + level)
        }
// show a popup with custom tasks here...return false; } </script>

Depending on your implementation, once you select the task from the list, you can directly make a postback and update the database to add the task and set the correct ParentID.

Regards,
Peter Milchev
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Tags
Gantt
Asked by
Jerry
Top achievements
Rank 2
Iron
Iron
Answers by
Peter Milchev
Telerik team
Share this question
or