JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums Gantt Is there an event that fires when a connection is removed?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #111950
    Adam Dawes
    Participant

    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?

    #111956
    Markov
    Keymaster

    Hi 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,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

    #111957
    Adam Dawes
    Participant

    Hi 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 and getConnectionDetails methods to find the connection by its id (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 calling getTask(event.detail.item.source) but this just returned undefined.

    What am I missing?

    Thanks,

    Adam.

    #111965
    Adam Dawes
    Participant

    Just for info I have managed to work around this by calling getConnections during the opening event and caching the results, and then when the itemRemove 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 by getConnectionDetails should be available in the itemRemove event (including the startTask and endTask objects) rather than just the limited information currently available.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.