JointJS - List of items in Node with ports

315 views
Skip to first unread message

Michał Brzozowski

unread,
Sep 9, 2021, 11:53:25 AM9/9/21
to JointJS
Hello, I'm struggling with an issue and I don't know if it's possible to achieve. I'm trying to make a Node with HeaderedRectangle, which in body will contain a list of items with ports, to which we can connect. I don't know how to add a list of items with ports, I can only add a text there, so I decided to choose HeaderedRecord and that's what I achieve:
node.png
The problem here is, these ports, are for whole Node, and not for the specific item. Do you know maybe how and if it is possible to achieve with HeaderedRectangle or HeadererRecord? Thank you

Roman Bruckner

unread,
Sep 20, 2021, 8:45:32 AM9/20/21
to joi...@googlegroups.com
Hi,

one would have to override some of the Record methods.

The similar shape can be defined as shown on the link below. Each item in the demo is a port (you can even use `magnet`, `magnetSelector`, `highlighterSelector` properties to tell where the links should connect).


Best,
Roman

--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jointjs/093f054f-d5a2-4990-8eb4-6b196fa7f7a6n%40googlegroups.com.


--

larenius gecko

unread,
Oct 11, 2021, 10:52:10 AM10/11/21
to JointJS
Hello Roman,

I stumbled across this thread in the search of a solution to a similar problem. I want to display a list of items underneath an element, and link specific items to a whole other list. 
The demo you provided already helped me, however I still struggle to link an element with a port.
This is the error i receive in the console:

Uncaught Error: LinkView: invalid source cell


Are you keen to elaborate more detailed how exactly I can select a port as a target/source for a link?

Hope you can help me if you see this soon enough.

Tanks in advance,
Laris

Roman Bruckner

unread,
Oct 11, 2021, 11:37:12 AM10/11/21
to joi...@googlegroups.com
Hi Laris,

I am not sure whether I understand correctly. Do you mean how to programmatically connect a link to a port?

link.set('target', { id: 'element_id', port: 'port_id' });

The error you see happens when the `id` provided does not exist in the graph. e.g.

link.set('target', { id: 'non_existing_element_id' });

Best,
Roman



larenius gecko

unread,
Oct 12, 2021, 10:12:38 AM10/12/21
to JointJS
Hey Roman, 

Thanks a lot for the quick answer, this turned out to be my problem. I m pretty new to jointjs so I was not aware that you can set a target with an id like you described there.
Previously I was using links like this

link.source(element1)
link.target(element2)

to connect two elements and it worked up to this point. When i looked up links for the first time I was thinking the link source/target always requires the element and not just the id, so I had problems with the ports.

Anyways you guided me into the right direction, now it is more clear to me. Thank you :)


Best Regards
Laris

Reply all
Reply to author
Forward
0 new messages