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
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>functionfindTaskByUid(gantt, uid) {
for (var i = 0; i < gantt.get_allTasks().length; i++) {
var task = gantt.get_allTasks()[i];
if (task._uid == uid) {
return task;
}
}
}
functionfindTaskByID(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;
}
}
}
functiontoolbar_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...returnfalse;
}
</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.