Expand/Collapse HeaderedRecord

88 views
Skip to first unread message

Mike Aubury

unread,
Dec 9, 2019, 8:51:54 AM12/9/19
to JointJS
Hi, 
I'm using Rappid 2.4 and I've got a shapes.standard.HeaderedRecord (example hopefully attached)

Is there anyway to get it so it can expand and collapse ? 
(Ideally - I'd like to just show the header in the collapsed state, showing the A,B,C when expanded)

I've seen "toggleItemCollapse" but not got any idea how to use it, or if there's something easier i'm missing..

Thanks in advance.
2019-12-09_1347.png

Roman Bruckner

unread,
Dec 10, 2019, 9:37:16 AM12/10/19
to joi...@googlegroups.com
Hi Mike,

I guess you can empty the `items` attribute on the model when collapsing and put it back when expanding. There is no support on the view, which would do it without modifying the model's data (Unless you override the RecordView and make necessary changes).

Here' s a simple example how to do it in the DataMapping demo from the Rappid package.

// example.js
order.attr('header/event', 'element:header:pointerdown');

// data-mapping.js
paper.on('element:header:pointerdown', function(view) {
    var model = view.model;
    var items = model.get('items');
    var collapsedItems = model.get('collapsedItems');
    if (collapsedItems) {
        model.set({
            items: collapsedItems,
            collapsedItems: null
        });
    } else {
        model.set({
            items: [],
            collapsedItems: items
        });
    }
});

Is that solution ok with you?

Best regards,
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/7fe8ffa1-27cf-424b-938e-ca691aa584de%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages