Currently we do not have a proper example demonstrating LoadOnDemand with RadDaigram.
However, we have modified our OrgChart example a bit a and we are attaching it for you. Please keep in mind that our OrgChart sample is not designed to be a real LoadOnDemand app so we hope this is just a good starting point, not a complete solution. The example shows only how to load the data we need when we expand a node. Data Validation, remove nodes on collapsing and so on are not completed.
Basically, you can have an event handler / method which fires on expansion of a node and Load the data you need. In our OrgChart sample this is ToggleChildrenVisibility event handler:
var stream = Application.GetResourceStream(
XElement dataXml = XElement.Load(stream.Stream);
//XContainer element = dataXml.Elements("Node").Where(n => n.Attribute("Email").Value == node.Email).FirstOrDefault();
XContainer element = FindXMLNodeByPath(dataXml, node.Path.Split(
receives a path to an item and returns the right XContainer from our XML:
XContainer FindXMLNodeByPath(XElement dataXML,
IEnumerable<XElement> currNodes = dataXML.Elements(
XContainer currElement =
currElement = currNodes.Where(n => n.Attribute(
).Value == item).FirstOrDefault();
currNodes = currElement.Elements(
Once again, this is just a modification of our OrgChart sample. In a real-world scenario the idea can be shortened in the following steps:
1) Load some root notes initially.
2) Catch an event when expand button is fired.
3) Find the child data from your source (XML, DB, not already loaded ViewModels).
4) Add the children ViewModels to the collection ViewModel of the Expanded item.
Hope this helps you proceed. If not, you can let us know more from your specific application requirements.
This way we would be better able to advice you and/or create a more-isolated sample.
the Telerik team