Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6696013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:17:27+00:00 2026-05-26T06:17:27+00:00

I have a javascript array of objects that I would like to use to

  • 0

I have a javascript array of objects that I would like to use to populate a RadTreeView.
I can’t figure out how to accomplish this from the client side other than manually writing my own binding method for my collection of objects.

Each object in my javascript array has

Id
ParentId
Value
Text

Is there no way to automatically populate an entire tree from this javascript data structure on the client side?
Do I have to do this 1-by-1? By traversing my array and recursively going down the tree?

I’m using a web service to get a JSON object with this data and I would like to build the tree fully, not just on the expanded node.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:17:27+00:00Added an answer on May 26, 2026 at 6:17 am

    Apparently, there’s no way to bind an entire tree from the client side. The most you can do is bind first-level nodes and as the user clicks on each one, you can populate the child nodes making another web method call.

    <telerik:RadTreeView OnClientNodeClicking="PopulateChild" DataTextField="Text" 
                                ID="datesTree" runat="server">
                                <WebServiceSettings Path="../AcmeWebService.asmx" Method="GetRootNodes" />
      <Nodes>
        <telerik:RadTreeNode Text="Root Node" ImageUrl="../images/truckicon.png"  ExpandMode="WebService" />
      </Nodes>
    </telerik:RadTreeView>
    

    Your GetRootNodes method can look like this:

    [WebMethod, ScriptMethod]
    public RadTreeNodeData[] GetRootNodes(RadTreeNodeData node, object context)
    {
        DataTable productCategories = GetProductCategories(node.Value);
        List<RadTreeNodeData> result = new List<RadTreeNodeData>();
        foreach (DataRow row in productCategories.Rows)
        {
            RadTreeNodeData itemData = new RadTreeNodeData(); 
            itemData.Text = row["Title"].ToString(); 
            itemData.Value = row["CategoryId"].ToString();
            if (Convert.ToInt32(row["ChildrenCount"]) > 0) 
            { 
                itemData.ExpandMode = TreeNodeExpandMode.WebService; 
            }
            result.Add(itemData);
        }
        return result.ToArray();
    }
    

    PopulateChild client-side method can be something like:

    function PopulateChild(sender, args) {
    var treeView = $find('datesTree');
    
        var nodeText = "";
    
        $.ajax({
            type: "POST",
            url: "../AcmeWebService.asmx/GetChildNodes",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: "{'nodeText': '" + nodeText + "','nodeValue': '" + args.get_node().get_value() + "','param2':'" + treeView.get_allNodes()[0].get_value() + "' }",
            success: function(msg) {
                if (treeView != null) {
                    treeView.trackChanges();
                    var parent = treeView.get_selectedNode() || treeView;
                    var count = parent.get_nodes().get_count();
                    for (var i = 0; i < msg.d.length; i++) {
                        var node = new Telerik.Web.UI.RadTreeNode();                                                
                        node.set_text(msg.d[i].Text);
                        node.set_value(msg.d[i].ParentID);
                        node.set_expanded(true);
                        parent.get_nodes().add(node);
                    }
                    treeView.commitChanges();
                }
            }
        });
    

    }

    And on the web service method to populate the child nodes can be something like:

    [WebMethod, ScriptMethod]
    public IEnumerable<YourNode> GetChildNodes(string nodeText, string nodeValue, int param2)
    {
       //call your DAL with any parameter you passed in from above
       IEnumerable<YourNode> nodes = ...
       return nodes;
    }
    

    Note 0 The method above does not return an array of RadTreeNodeData. It can be any collection of your own custom objects. Same goes for the GetRootNodes it’s just that I copied that one from Telerik’s website 😉

    Note 1: I had a similar scenario once and I used this technique of loading first-level nodes initially and loading the others on client click. Some of the code I posted here is a slimmed down version of my original code.

    I hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating my own JavaScript Array-like object and I have methods that call closures.
I have a one-dimensional array of strings in JavaScript that I'd like to turn
I have a line in a javascript function that sort an array of objects
I have a JavaScript array of objects with the same properties each, something like
I know that given enough time I'll figure this out, but it sure would
I have a collection of objects in JavaScript like this: Object collection = new
I have an array of JavaScript objects: var objs = [ { first_nom: 'Laszlo',
1) I have this Javascript array: lang=new Array(); lang[sq]=Albanian; lang[ar]=Arabic; lang[en]=English; lang[ro]=Romanian; lang[ru]=Russian; 2)
I have an external JavaScript that contains: function random_imglink(){ var myimages=new Array() myimages[1]="http://sevir.sitegoz.com/jchs/Banner1.png" myimages[2]="http://sevir.sitegoz.com/jchs/banner2.png"
I have an array I've created in JavaScript. The end result comes out to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.