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

innerHTML of get_textElement() not persisting

1 Answer 99 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
CodeR
Top achievements
Rank 2
CodeR asked on 28 Apr 2009, 04:46 AM
Hi I am using version 2009.01.0402.35 of the RadTreeView.
I am attempting to put simple HTML (mainly BRs and  s) into the text of RadTreeNodes via clientside Javascript.
I realise that set_text() will strip the tags and found in the forums to set the innerHTML propertry of .get_textElement() instead.
I also understand that will not be persisted after a postback.
My issue is however, when I rearrange the nodes, ie move this node up or down a level in the tree, again using entirely client javascript, the node's text is set back to it's original nonHTML value.

I am considering putting the value I want inside a custom attribute and then after the reshuffle operation restting the innerHTML from the attribute but consider this to be clunky as well as wasting memory, viewstate and CPU cycles.

Alternatively is there a way of insterting a new lines (or line breaks) into the text value of the node without using HTML?

Thanks

1 Answer, 1 is accepted

Sort by
0
CodeR
Top achievements
Rank 2
answered on 28 Apr 2009, 06:10 AM
Have found a solution for this if anyone else is interested.
Basically I wrote a short function to dump the innerHTML values into an array. Once I have put the node where it needs to go I can call the reverse operation which using the array resets the innerHTML values.

function

 

backupVals(node, arr) {

 

 

 arr[arr.length] = node.get_textElement().innerHTML;

 

for (idx = 0; idx < node.get_nodes().get_count(); idx++) {

 

 

     backupVals(node.get_nodes().getNode(idx), arr);

}

}

 

 

function

 

restoreVals(node, arr) {

 

 

 node.get_textElement().innerHTML = arr[0];

 

for (idx = 0; idx < node.get_nodes().get_count(); idx++) {

 

    restoreVals(node.get_nodes().getNode(idx), arr.slice(1));

 

}

}

 

var

 

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

 

 

parent.get_nodes().add(newNode);  

 

while (parent.get_nodes().get_count() > 1) {  

 

    var currentNode = parent.get_nodes().getNode(0);

 

    var tempVals = new Array();

    backupVals(currentNode, tempVals);

    parent.get_nodes().remove(currentNode);

    newNode.get_nodes().add(currentNode);

    restoreVals(currentNode, tempVals);

}

 

 

Tags
TreeView
Asked by
CodeR
Top achievements
Rank 2
Answers by
CodeR
Top achievements
Rank 2
Share this question
or