This is a migrated thread and some comments may be shown as answers.

nodePopulating is not calling

1 Answer 42 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mahmood Ahmad Tahir
Top achievements
Rank 1
Mahmood Ahmad Tahir asked on 02 Oct 2009, 11:59 AM
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);
}

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 06 Oct 2009, 03:50 PM
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.
Tags
TreeView
Asked by
Mahmood Ahmad Tahir
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or