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

Client side insert and "get_parent() is null or not an object"

1 Answer 89 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
aquillin
Top achievements
Rank 1
aquillin asked on 11 Feb 2008, 05:42 PM
I have created a function to move my treenodes up and down on the client side by creating a new node, copying the old node information to the new node, then removing the old node and inserting the new node into at a index offset by 1.  Code:

var

newNode = new Telerik.Web.UI.RadTreeNode();

newNode.set_text(node.get_text());

newNode.set_value(node.get_value());

treeView().trackChanges();

var parent = node.get_parent();

var index = parent.get_nodes().indexOf(node);

var newIndex = null;

if(direction == "up")

    var newIndex = index - 1;

if(direction == "down")

    var newIndex = index + 1;

parent.get_nodes().remove(node);

parent.get_nodes().insert(index,newNode);

treeView().commitChanges();

This all works except after wards, when I try and access the parent of newNode, it says that "get_parent() is null or not an object."  I realize that in this function I have the parent object, but this is just a code snippet.  Soon after the newNode is created I will need to get it's parent, and it's parent's parent information.  This is done in a seperate function that does not have access to the parent object in the above code snippet.  Is this a known issue, or is there a fix?

1 Answer, 1 is accepted

Sort by
0
aquillin
Top achievements
Rank 1
answered on 12 Feb 2008, 02:30 PM
Nevermind, this does not seem to be an issue.  I really don;t know what I was doing wrong, but after alittle refactoring and code cleaning it started to work.  I was probably passing the reference to the node incorrectly or something like that. 
Tags
TreeView
Asked by
aquillin
Top achievements
Rank 1
Answers by
aquillin
Top achievements
Rank 1
Share this question
or