Getting a list item based on its data

Hi

There are methods for finding nodes and links based on their data, is there anything similar for an item held in an item array? We have just started to use item arrays so we have more control over their appearance and we have implemented the selection highlighting as shown in

We have a Table of Contents in our app that when clicked should highlight the selected item in the list. The Table of Contents knows the ID of the item but isn’t aware of the GoJS item.

I think you want Panel | GoJS API. However, note that it doesn’t work for Array items that are numbers or strings, because it’s too common for there to be duplicate string or number values in an Array.

GoJS does not know about any unique “identifier” for each Array item.

Also note these functions when dealing with Table Panels: Panel.findColumnForLocalX and Panel.findRowForLocalY.

Thanks, I got it working. The findNodeForKey method is very handy for the way our app is structured, it would be great if there were similar methods for links and items, or just a single method for all types of object. I appreciate items don’t have a key but if they did we could treat them in the same way as every other object

If you set GraphLinksModel | GoJS API to a link data property name, you will be able to call GraphLinksModel | GoJS API and Diagram | GoJS API.

Thanks, I’d been looking in the wrong place!

Note that if you want to call Diagram.findPartForKey to get Links, you’ll need to make sure that the keys for link data do not conflict with the keys for node data.

It might be safer to call GraphLinksModel.findLinkDataForKey and then Diagram.findPartForData.

We’re OK on that score, all our keys are GUIDs