innerHTML of get_textElement() not persisting

2 posts, 0 answers
  1. CodeR
    CodeR avatar
    36 posts
    Member since:
    Apr 2005

    Posted 27 Apr 2009 Link to this post

    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
  2. CodeR
    CodeR avatar
    36 posts
    Member since:
    Apr 2005

    Posted 28 Apr 2009 Link to this post

    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);

    }

     

     

Back to Top