How do I set the text of a TreePanel node in JavaScript?

  1. #1

    How do I set the text of a TreePanel node in JavaScript?

    I have added a child node to the TreePanel using appendChild.

    text: 'Node 1',
    leaf: true,
    iconCls: '#Briefcase'
    How can I then change this text once its been added?

    I have tried the following but the node text doesn't update until I expand/collpase the parent : = 'New Text';
    selectedNode.set('title', 'New Text');
    selectedNode.set("text", 'New Text');;
    Is there another way to force the change?
  2. #2
    Hello @paulschofield!

    The last option you are trying to use looks right. But you didn't provide a runnable test case, all I can do is test with what we have; and I chosen the TreePanel basic example.

    There, if I just run App.TreePanel1.getRootNode().getChildAt(0).set('text', 'Bach');, I have the node updated correctly.

    You can try by yourself in the example. If you can show the issue or the scenario via a runnable example, we probably could help you better.

    Anyway, hope the example above helps you find out what's wrong in your scenario.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 2
    Last Post: Aug 10, 2015, 4:00 PM
  2. Replies: 11
    Last Post: Feb 06, 2013, 6:09 PM
  3. [CLOSED] TreePanel Node Check Through Javascript
    By Patrick_G in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 15, 2012, 4:36 PM
  4. Replies: 1
    Last Post: Apr 08, 2010, 7:28 PM
  5. [CLOSED] Is it possible to apply CSS to a node text in a TreePanel?
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 04, 2010, 5:07 PM

Posting Permissions