Thanks Plamen.
I've tried that but it doesn't fully work.
If I start at the top of the tree and expand nodes to the lowest level eg:
- TMP Number 1
...- Module1
......- CLO1
.........- MLO1
...+ Module2
...+ Module3
...+ Module4
If I then close the entire structure by clicking the - next to TMP Number 1, followed by pressing its +, then I click Module1 (not its +) I get:
- TMP Number 1
...+ Module1
...Module2
...Module3
...Module4
...+ Module1
...Module2
...Module3
...Module4
In other words, the structure is duplicated. If I repeat the close of the root element, then its + and Module1 I get the tree repeated three times.
If I click the + signs to re-expand the tree, all works fine and the tree is populated from the database.
There seems to be a problem with clicking on the actual item text.
If I take out the code you suggested, the duplication no longer happens, but I'm back to my original problem of the tree being cached and not updating from the database.
I'm using 2011.1.519.35
I have no code other than the web service code populating the list:
public static RadTreeNodeData[] GetChildNodes(RadTreeNodeData node) {
int langId = Convert.ToInt32(HttpContext.Current.Session["LangId"]),
orgId =
Convert.ToInt32(HttpContext.Current.Session["OI"]);
KuriousDataContext db = new KuriousDataContext();
// If the node is the root TMP, the node value is the Id of the TMPNode
// record it represents, otherwise, it is the Id of the TMPNodeLink record
// whose child node id points at the node.
List<TMPNodeLink> childNodeList = db.FindTMPNodeLinks(Convert.ToInt32(node.Value)).ToList();
// Work out the node level we are looking at
int level = Convert.ToInt32(node.Attributes["NT"]) + 1;
// Get the first item of the element list which is the element name
var titleElement = db.FindTMPElement(Convert.ToInt32(HttpContext.Current.Session["OI"]), level, CConstants.TMPPR_TITLE);
List<RadTreeNodeData> result = new List<RadTreeNodeData>();
foreach (TMPNodeLink nodeLink in childNodeList) {
RadTreeNodeData childNode = new RadTreeNodeData();
TMPNodeData nodeData = db.FindTMPNodeData(nodeLink.TMPNodeId, titleElement.Id, langId);
childNode.Text = (nodeData ==
null ? "[Not Found]" : nodeData.ValueText);
childNode.Value = nodeLink.Id.ToString();
if (db.HasAnyChildTMPNodes(nodeLink.Id)) {
childNode.ExpandMode =
TreeNodeExpandMode.WebService;
}
else {
// childNode.ExpandMode = TreeNodeExpandMode.ClientSide;
}
//childNode.ImageUrl = NodeTypeImageURL((int)_node.NodeTypeId);
childNode.Attributes.Add(
"NT", nodeLink.TMPNode.NodeTypeId.ToString());
result.Add(childNode);
}
node.ExpandMode =
TreeNodeExpandMode.WebService;
return result.ToArray();
}