RadControls for ASP.NET AJAX Case:
A Load On Demand TreeView for which:
The ExpandMode for Load On Demand Nodes is either ServerSideCallBack or WebService.
The NodeClick server-side event is handled.
A Node is expanded when clicked (in either the OnClientNodeClicking or OnClientNodeClicked event handlers).
Problem:
Due to timing issues in case ExpandMode for the clicked Node is:
Resolution:
Ensure that the NodeClick event fires after the Node finishes loading its Nodes:
Expand the Node in the OnClientNodeClicking event handler. If the Node's ExpandMode is ServerSideCallBack or WebService and the Node does not have children, cancel the event. Below is an example:
CopyJavaScript
function onClientNodeClicking(sender, eventArgs){
var node = eventArgs.get_node();
if ((node.get_expandMode() > 1) &&
(node.get_nodes().get_count() == 0))
{
eventArgs.set_cancel(true);
}
node.expand();
}
Handle the OnClientNodePopulated event and select the expanded Node in the event handler, like this:
CopyJavaScript
function onClientNodePopulated(sender, eventArgs){
eventArgs.get_node().select();
}