Each node on my graph has an itemArray with a variable number of items in it (tags), however I only want the first two tags shown with an indicator to show that there are more .
I’m showing a list of all items in a tooltip (this bit is done)
How would I render only the first two items of my array and then optionally show a text label saying “+ x more…” if there are more than two?
Here’s my code so far:
$(
go.Panel, 'Horizontal', new go.Binding('itemArray', 'tags'),
{
itemTemplate: $( go.Panel, 'Auto',
$(go.Shape, 'RoundedRectangle'),
$(go.Panel, 'Horizontal', $(go.TextBlock, 'Link Label', new go.Binding('text', 'text')))
)
}
)
My model data is along the lines of:
modelData.nodeDataArray = [
{
// ... other properties
tags: [
{ text: "tag 1", url: "#" },
{ text: "tag 2", url: "#" },
{ text: "tag 3", url: "#" },
{ text: "tag 4", url: "#" },
]
}
]
Desired output:
[tag 1] [tag 2] + x more...