Load On Demand - get lowest level when parent is checked

6 posts, 0 answers
  1. Logan
    Logan avatar
    3 posts
    Member since:
    Jun 2013

    Posted 11 Jun 2013 Link to this post

    I have a RadTreeView that loads nodes on demand via a web service.  Only the node at the very bottom level has a value, which is what I need to retrieve.  If the user checks a node and then expands it, it's children will be checked all the way to the lowest level, and the value will be provided.  However, here is my problem: When the user selects a parent node (that is NOT expanded) I cannot figure out how to get the value of its children's lowest level nodes.  Essentially, when a node is selected I need it to retrieve and check all of its children.  Is this possible?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Jun 2013 Link to this post

    Hi,

    Try the following code.

    JS:
    function OnClientNodeClicked(sender, args)
     {
     var currentNode = args.get_node();
     if (args.get_node()._hasChildren())
       {
      var allNodes = currentNode.get_allNodes();
      if (currentNode.get_checked())
          {
      for (var i = 0; i < allNodes.length; i++)
           {
       allNodes[i].set_checked(false);
       currentNode.set_checked(false);
      }
       }
      else
          {
       for (var i = 0; i < allNodes.length; i++)
            {
        allNodes[i].set_checked(true);
        currentNode.set_checked(true);
        }
       }
       alert(args.get_node().get_lastChild().get_text()); // to get the last node of selected parent.
     }
     }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Logan
    Logan avatar
    3 posts
    Member since:
    Jun 2013

    Posted 11 Jun 2013 Link to this post

    Shinu, 

    Thank you for the reply.  The problem I am having with the code you provided is that:
    args.get_node()._hasChildren()

    returns false until the node is expanded and its children are loaded from the web service.  This is the main problem that I am running into.  My original idea was to force the node to expand, however .ExpandChildNodes() does not work with web service load on demand, and I cannot find any way to expand a node programatically.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Jun 2013 Link to this post

    Hi,

    To expand a node programatically please have a look into the following help documetation.
    Load On Demand expand on server-side Node click

    Thanks,
    Shinu.
  6. Logan
    Logan avatar
    3 posts
    Member since:
    Jun 2013

    Posted 17 Jun 2013 Link to this post

    Is it possible to expand the node being clicked AND the nodes that are being loaded from node.expand()? 
  7. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 18 Jun 2013 Link to this post

    Hello Logan,

    Please try using the approach  described in this help article - Expanding Nodes on a Single Click

    Regards,
    Kate
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017