I’m using CollapsingRecordNode and I want to programatically remove a CollapsingRecordNodeItemList (Which has the CollapsingRecordNodeItem + link) from a CollapsingRecordNode and insert it to another.
When I try to do the same somehow the link disappears.
if (oldStartNode != null)
{
oldStartNode.List.Remove(item.ParentList);
}
if (startNode != null && endNode != null)
{
startNode.List.Add(item.ParentList);
link.FromPort = item.Ports.First;
link.ToPort = endNode.Ports.First;
link.InvalidateViews();
}
Doc.FinishTransaction("Updating link start");
}
Even when i save this to xml, the link info is missing from the xml.
Is something wrong with the above code? What is the best way to achieve what I’m trying to do?
When you do the oldStartNode.List.Remove, you pull the node out of the document, which sets all it’s children’s parents (including ports) to null. A side effect of that is for all links connected to that port to be removed.
so, you need to disconnect the link from the FromPort before that happens…
This code works for me, at least in the situation I’m testing. I’m not 100% sure I’m accurately reproducing your entire scenario. note I’ve commented out a couple of lines.