nodePopulating is not calling

2 posts, 0 answers
  1. Mahmood Ahmad Tahir
    Mahmood Ahmad Tahir avatar
    1 posts
    Member since:
    Oct 2009

    Posted 02 Oct 2009 Link to this post

    Hi,

    Im using treeview control in MVC through client side binding and client side method which is assigned to OnClientNodePopulating event, is not calling.

    following is the asp.net code


     <telerik:RadTreeView runat="server" ID="RadTreeView1" DataTextField="SearchKeyword"
            DataValueField="id" LoadingStatusPosition="AfterNodeText" OnClientNodePopulating="nodePopulating" >
            <DataBindings>
                <telerik:RadTreeNodeBinding Depth="0" ExpandMode="WebService" />
            </DataBindings>
        </telerik:RadTreeView>


    client side code:

    function onSuccess(result, node) {
        debugger;
        node.hideLoadingStatus();
        //the result in JSON format is available as a "d" field
        var data = result.d;

        //Traverse the array of objects and create combobox items
        for (var i = 0; i < data.length; i++) {
            var dataItem = data[i];

            var childNode = new Telerik.Web.UI.RadTreeNode();
            childNode.set_text(dataItem.Text);
            childNode.set_value(dataItem.id);
            childNode.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.WebService);
            node.get_nodes().add(childNode);
        }
        node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ClientSide);
        node.expand();
    }

    function nodePopulating(sender, args) {
        debugger;
        var node = args.get_node();
        node.showLoadingStatus(sender.get_loadingMessage(), sender.get_loadingStatusPosition());
        //get only the child nodes of the current node
        var filter = "&$filter=parentId eq " + node.get_value();

        //Call the ADO.NET Data Service
        $telerik.$.ajax({
            type: "GET", // HTTP method
            url: '<%= ResolveUrl("TreeViewAdoNetService.svc/Links?") %>' + filter, // ADO.NET DataService URL
            contentType: "application/json; charset=utf-8", //request the result to be in JSON
            dataType: "json",
            success: function(result) { //callback method to invoke when the request is complete
                onSuccess(result, node);
            }
        });
        args.set_cancel(true);
    }

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 06 Oct 2009 Link to this post

    Hello Mahmood Ahmad Tahir,

    You need at least one root node with ExpandMode=WebService which can be expanded in order to trigger the load on demand (thus nodePopulating) event. Can you confirm the treeivew has at leas one root node?

    Regards,
    Albert,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top