johnllao

June 6, 2008

Displaying a progress indicator during DemandLoad of the UltraWebTree

Filed under: ASP.NET — Tags: , , — johnllao @ 11:42 am

Declare InitializeTree and DemandLoad event handlers in the ClientSideEvents of the UltraWebTree.

<ClientSideEvents InitializeTree="func_initializeTree" DemandLoad="func_demandLoad" />

The DemandLoad event handler will respond when the user click on a node and process an ajax postback to retrieve thechild nodes. In this handler you can display any progress indicator message.

The InitializeTree event handler will act like the callback, this is assumed because the UltraWebTree does not have any AfterDemandLoad event. In this handler you can hide the progress indicator message.

 

var _currentNodeId = '';
var _currentNodeText = '';

function func_initializeTree(treeId)
{
    var tree;
    tree = igtree_getTreeById(treeId);
    if(_currentNodeId.length > 0 && _currentNodeText.length > 0)
    {
        var node = igtree_getNodeById(_currentNodeId);
        node.setText(_currentNodeText);
    }
    _currentNodeId = '';
    _currentNodeText = '';
}

function func_demandLoad(treeId, nodeId)
{
    var tree = igtree_getTreeById(treeId);
    var node = igtree_getNodeById(nodeId);
    _currentNodeId = nodeId;
    _currentNodeText = node.getText();
    node.setText(_currentNodeText + ' [Loading...]');
}

Blog at WordPress.com.