JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Gantt › Is there an event that fires when a connection is removed?
Tagged: gantt connections
- This topic has 3 replies, 2 voices, and was last updated 1 week, 3 days ago by Adam Dawes.
-
AuthorPosts
-
December 13, 2024 at 9:36 am #111950Adam DawesParticipant
I would like to be able to set my code to respond to a connection being double-clicked or removed from the chart, but I can’t find any way to do either of these things.
Double-clicking a connection by default opens the “Delete link” prompt. My ideal would be to disable this prompt and handle the double-click myself but no suitable event appears to fire when the double-click takes place. The
opening
event is triggered, but I can’t seem to identify the details of the connected tasks in order to handle this.Alternatively if I allow the “Delete link” prompt to appear, I would like an event to fire when the user clicks OK and the connection is removed. I would need to know the two tasks that were involved in the connection so that I can process them myself.
Is any of this possible? If so, how do I do it? If not, could this be considered for a future update?
December 13, 2024 at 12:05 pm #111956MarkovKeymasterHi Adam,
There is an event and it is ‘itemRemove’. After the connection is removed, the itemRemove event is fired with event.detail.type === ‘connection’.
Regards,
MarkovSmart UI Team
https://www.htmlelements.com/December 13, 2024 at 1:22 pm #111957Adam DawesParticipantHi Markov,
Thank you for highlighting this, I had overlooked that connections were treated as items too. That event does indeed fire with the type set as you describe.
However I’m having trouble identifying which actual tasks were on each side of the connection. For example, for a connection I have deleted in testing, the
detail
object shows me the following:- id: “16-17-1”
- item.source: 16
- item.target: 17
- item.type: 1
- type: “connection”
That’s all great, but it’s not including my task id values for the source and target tasks. The 16 and 17 appear to be internal indices into the Gantt chart tasks. How can I obtain the actual underlying task items from these two values in order to read their properties?
I tried using the
getConnections
andgetConnectionDetails
methods to find the connection by itsid
(the data returned by these methods includes everything I need) but the deleted connection has already been removed by this point and is not recognised by either method. I tried callinggetTask(event.detail.item.source)
but this just returnedundefined
.What am I missing?
Thanks,
Adam.
December 16, 2024 at 11:36 am #111965Adam DawesParticipantJust for info I have managed to work around this by calling
getConnections
during theopening
event and caching the results, and then when theitemRemove
event fires, looking back in the cache to find the item with the provided connection id. This does allow me to then identify the tasks that were linked by the connection. It would be great if this data were available automatically however: the full information returned bygetConnectionDetails
should be available in theitemRemove
event (including thestartTask
andendTask
objects) rather than just the limited information currently available. -
AuthorPosts
- You must be logged in to reply to this topic.