Product: bryntum/gantt-trial@4.2.4
How to set default startDate and endDate while adding tasks. our requirement is that we want to set the default value null. I tried to set values in "beforeadd" event but had no success.
If we are talking about addTaskAbove/addTaskBelow, here is docs for this feature https://bryntum.com/docs/gantt/#Gantt/feature/TaskMenu
Menu items you need are add> addTaskAbove and add> addTaskBelow
By default it just copies data from referral task, but you may apply your changes like this:
features : {
taskMenu : {
// Extra items for all events
items : {
add: {
menu : {
addTaskAbove : {
onItem: async ({taskRecord}) => {
const task = await gantt.addTaskAbove(taskRecord);
task.name = 'test'; // or whatever you need
gantt.project.commitAsync();
}
}
}
}
}
}
}
All the best,
Alex
I get the following error. i have attached my AppConfig file for your reference.
Uncaught (in promise) ReferenceError: gantt is not defined
at MenuItem.onItem (AppConfig.js:162)
at MenuItem.callback (gantt.module.js:515)
at MenuItem.trigger (gantt.module.js:515)
at MenuItem.doAction (gantt.module.js:515)
at Menu.triggerElement (gantt.module.js:515)
at Menu.onMouseClick (gantt.module.js:515)
at HTMLDivElement._0x259e8d (gantt.module.js:515)
at HTMLDivElement.o (LogRocket.min.js:2)
gantt
in the code snippet above is a variable with the Gantt instance. In case you import AppConfig
into the file where you create a gantt instance, better might be to move this method declaration to the place where it's more obvious to you how to get a link to the Gantt instance.
All the best,
Alex
Actually, you get reference to the owning gantt
in the onItem
listener. This should work for you:
taskMenuFeature: {
// Extra items for all events
items: {
add: {
menu: {
addTaskAbove: {
onItem: async ({source:gantt, taskRecord}) => {
const task = await gantt.addTaskAbove(taskRecord);
task.name = 'test'; // or whatever you need
gantt.project.commitAsync();
}
},
addTaskBelow: {
onItem: async ({source:gantt, taskRecord}) => {
const task = await gantt.addTaskBelow(taskRecord);
task.name = 'test'; // or whatever you need
gantt.project.commitAsync();
}
}
}
}
}
},
Mind also the name - we suffix feature names with Feature
word in Vue.