August 23, 2019, 11:39am
when i create the link, the source and target come with id task and i need to come with another value. I have 2 primary keys.
Is that possible to receive sourcetask and targettask on event “onBeforeLinkAdd”? Or receive another values on source and target.
August 26, 2019, 4:10pm
You can change link parameters in the
onBeforeLinkAdd event handler:
But please note that the event is not asynchronous. The parameters should be ready before you start adding a link, otherwise, it won’t work. Here is the snippet:
If you want to obtain the values from the database or somewhere else, you need to wait until the link is added and modify the parameters in the
onAfterLinkAdd event handler:
Here is the snippet:
You can check the following topic, you can find the answers to similar questions:
Like to know what’s the best way to know what is the affected task when a task link has been added, updated, or removed.
Currently, the onAfterLinkAdd, onAfterLinkUpdate, onAfterLinkDelete, only returns the link object and does not tell what is the task that is being affected. Looking more towards the affected source task, at the moment but will be great to know both source and target affected task.
August 26, 2019, 4:32pm
Thank you for you answer.
I need another parameter on event “onBeforeLinkAdd” for example all the object of the source task and the all the object of the target task and not only the id’s.
Is that possible?
August 27, 2019, 11:47am
You can obtain the link object with the
source properties from the
Or by using the
Then you can get the task objects by using the
var target_task = gantt.getTask(link.target)
var source_task = gantt.getTask(link.source)