Programmatically selected nodes can't get_nodes()

2 posts, 0 answers
  1. Seth
    Seth avatar
    66 posts
    Member since:
    Oct 2009

    Posted 31 Jan 2013 Link to this post

    We are using 2 treeviews to allow users to move items from one to the other.  After moving the selected items, we are programmatically setting the next node available as selected. When we try to multi-select again after the move we get the following error:

    Microsoft JScript runtime error: Unable to get value of the property 'get_nodes': object is null or undefined

    Here is a snippet of our JS source.
    function Left() {
        if (availableTree.get_selectedNode()) {
            var sourceNodes = availableTree.get_selectedNodes();
            var index = sourceNodes[0].get_index();
            var destNodeList = selectedTree.get_nodes();
            var destNode;
            if (destNodeList) {
                destNode = destNodeList.getNode(0);
            onNodeDroppingPrivate(availableTree, sourceNodes, destNode, "add");
            if (availableTree.get_nodes().get_count() == index) {
                index = index - 1;
        else {
            alert("Please select a service level to transfer");
    function onNodeDroppingPrivate(sender, sourceNodes, destinationNode, position) {
        var retVal = dropOnTree(sourceNodes); /*gets value of dragged node*/
        if (retVal != "0") {
            clientSideEdit(sender, sourceNodes, destinationNode, position);
        else {
            alert("There are no service levels to transfer.");
    function dropOnTree(sourceNodes) {
        var text = "";
        if (sourceNodes.length) {
            var i;
            for (i = 0; i < sourceNodes.length; i++) {
                var node = sourceNodes[i];
                if (node.get_attributes().getAttribute("Category") == "true") {
                    node = node.get_nodes().getNode(0);
                text = node.get_value();
        return text;
    function clientSideEdit(sender, sourceNodes, destinationNode, position) {
        if (destinationNode)
            for (var i = 0; i < sourceNodes.length; i++) {
                var sourceNode = sourceNodes[i];
                var sourceParent = sourceNode.get_parent();
                if (sourceParent.get_nodes().get_count() == 0) {
                    var node = new Telerik.Web.UI.RadTreeNode();
                    if (sourceParent.get_id() == availableTree.get_id())
                        node.set_text("All available service levels have been selected.");
                        node.set_text("No service levels have been selected.");
                if (position == "over") insertAfter(destinationNode, sourceNode);
                if (position == "above") insertBefore(destinationNode, sourceNode);
                if (position == "below") insertAfter(destinationNode, sourceNode);
                if (position == "add") add(destinationNode, sourceNode);
    function add(destinationNode, sourceNode) {
        var destinationParent = destinationNode.get_parent();
        GetAttribute(destinationParent, sourceNode);
        /* If destination parent contains 'No Nodes exist', new node added takes its place*/
        if (destinationParent.get_nodes().getNode(0).get_value() == "0") {
            AddTheEditButton(destinationParent.get_nodes().getNode(0), destinationParent.get_nodes().getNode(0));
        else {
            if (destinationParent.get_id() == selectedTree.get_id()) {
                addEditButton(destinationNode, sourceNode, "add", 0);
            else {
        return "false";

  2. Kate
    Kate avatar
    1898 posts

    Posted 05 Feb 2013 Link to this post

    Hello Seth,

    Please take a look at this demo of the RadTreeView control where you can find a working example of the functionality that you are trying to achieve. In the demo, you can easily select multiple nodes the first time the drag and drop them (repeating these steps does not invoke any exception). Give it a try and in case it does not help I would suggest that you open a support ticket where you can attache you simplified runnable project so we can inspect it locally and help you out.

    the Telerik team
    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 their blog feed now.
Back to Top