This example demonstrates how to achieve the best performance with RadTreeView when
dealing with large ammounts of data (nodes). The important steps are:
- Use Web Service load on demand.
Web Service load on demand does not request the page and avoids the execution of
the page life cycle. Less data is transferred between the client and the server.
- Set the PersistLoadOnDemandNodes property to false.
Persistence of nodes loaded on demand is enabled by default. This is required if
you need load on demand nodes to trigger server side events (NodeClick, NodeDrop).
If you don't consume the NodeClick or NodeDrop events you can disable the persistence
of nodes loaded on demand to improve the performance.
- The EnableViewState property is set to false.
ViewState is not required if PersistLoadOnDemandNodes is set to false. Disabling
it would save some output.
- The implementation of the Web Service methods uses two optimization techniques to
decrease the size of the generated JSON output:
- The return type of the web method is IEnumerable. This prevents the serialization
of the type name in the JSON output:
[WebMethod]
public IEnumerable GetNodes(RadTreeNodeData node, IDictionary context)
{
int numberOfNodes = 1000;
List<NodeData> nodes = new List<NodeData>();
for (int i = 0; i < numberOfNodes; i++)
{
NodeData nodeData = new NodeData();
nodeData.Text = "Node " + i;
nodes.Add(nodeData);
}
return nodes;
}
- The web method returns only the data required by the application. In this case only
the node's Text property is serialized by using a custom class - NodeData. You should
prefer this approach over using the RadTreeNodeData class to preserve output size:
class NodeData
{
private string text;
public string Text
{
get { return text; }
set { text = value; }
}
}
The OnClientNodePopulating and OnClientNodePopulated events are used only to measure
the time requred to perform the load on demand operation. Consuming them is not
required for the proper operation of RadTreeView in this scenario.
Consuming the OnClientNodeClicked event is used to trigger server side event when
the user clicks a node.