The maintask should be assigned to nobody ,only the subtask can be assigned
in current situation it works ,but when i create a new maintask it can be assigned
Support Forum
- Attachments
-
- 媒体3.mp4
- (11.46 MiB) Downloaded 37 times
You need to use https://bryntum.com/docs/gantt/api/Gantt/feature/CellEdit#event-beforeCellEditStart.
Here is an example of how you can achieve it:
listeners : {
beforeCellEditStart() {
if (parentTask) {
return false;
}
}
}
beforeCellEditStart({ editorContext }) {
const { column, record } = editorContext;
console.log(column, record)
if (column.type === 'resourceassignment' && record.originalData.children) {
// prevent editing percentdone
return false;
}
},
This is my current code, but when I create a new task and add subtasks to it, the task still assigns people
You need to override the addSubtask
function in Gantt
.
Here is how you can override it:
class MyGantt extends Gantt {
addSubtask(taskRecord) {
// if the task is not assigned to a person then add the subtask
if (!taskRecord.resources.length) {
const result = this.addTask(taskRecord, { asChild : true });
this.toggleCollapse(taskRecord, false);
return result;
}
}
}
Then use the customized MyGantt
instead of Gantt
new MyGantt({ ... });
Please check my code, I wrote this method but it doesn't seem to trigger
- Attachments
-
- advanced examples 3.zip
- (165.76 KiB) Downloaded 30 times
Oh, if you're using angular then don't use that. You should use the taskMenu
feature for this.
Please check docs : https://bryntum.com/docs/gantt/api/Gantt/feature/TaskMenu
Here is how you can achieve it :
taskMenu : {
items : {
add : {
menu : {
subtask : {
onItem : ({ taskRecord }) => {
if (!taskRecord.resources.length) {
const result = gantt.addTask(taskRecord, { asChild : true });
gantt.toggleCollapse(taskRecord, false);
return result;
}
}
}
}
}
}
},