RadTreeView for ASP.NET AJAX

RadControls for ASP.NET AJAX

The OnClientNodePopulating client-side event occurs just before child nodes are loaded on-demand. The ExpandMode property of the parent node should be ServerSideCallback or WebService for this event to fire. The event can be canceled.

The event handler receives parameters:

  1. The treeview instance that fired the event.

  2. Event arguments with functions:

    • get_node() retrieves a reference to the clicked on node.

    • get_context() retrieves an object that is automatically passed to a load-on-demand web service.

    • set_cancel() - call this function to specify wether the event should be canceled (true) or not (false).

    • get_domEvent() retrieves a DOM event object of the node population.

The example below shows how to prevent populating a "Network Locations" node. Note that the OnClientNodePopulated event does not fire when set_cancel() is called. See the Webservice Load-On-Demand topic for another example.

CopyASPX
<script type="text/javascript" language="javascript">

    function ClientNodePopulated(sender, eventArgs) {

        var node = eventArgs.get_node();
        alert("Node " + node.get_text() +
              " is populated with " +
              node.get_nodes().get_count() +
              " child nodes.");
    }

    function ClientNodePopulating(sender, eventArgs) {

        var node = eventArgs.get_node();
        if (node.get_text() == "Network Locations") {
            alert("You are not connected to the network");
            eventArgs.set_cancel(true);
        }
    }
</script>

<telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientNodePopulated="ClientNodePopulated"
    OnClientNodePopulating="ClientNodePopulating" OnNodeExpand="RadTreeView1_NodeExpand">
    <Nodes>
        <telerik:RadTreeNode runat="server" ExpandMode="ClientSide" Text="Search" ImageUrl="~/images/search.ico"
            Expanded="True" Value="1">
            <Nodes>
                <telerik:RadTreeNode runat="server" ExpandMode="ServerSideCallBack" Text="Recent Searches">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" ExpandMode="ServerSideCallBack" Text="Network Locations">
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeNode>
    </Nodes>
</telerik:RadTreeView>

The server NodeExpand event handler for the RadTreeView defined above:

See Also