0
votes

My Treepanel has the id 'treePanel' and works just fine.

Example path:

/subfolder3/abc

Expanding all with expandAll() works with the tree panel but expandPath() does not work.

Now, after some event I want to expand a path in my tree. However I can not make it.

So far I have tried:

var oTreePanel = Ext.getCmp('treePanel');

oTreePanel.expandPath('/subfolder3/abc'); // or '/subfolder3' or '/root/subfolder3'

There is no error message but also no change in the tree.

What to do?

EDIT

oTreePanel.selModel.getSelection()[0].getPath() is /root/.

What I tried:

  • path: /root => success is true and node says node.data.id="" and node.data.path=""

  • path: /root/ => success is true and node says node.data.id="" and node.data.path="/report_with_variables" (first node in the tree) and node.data.parentId= "root"

  • path: /root/subfolder3 to the path: success is false and node says node.data.id="" and node.data.path="" and node.getPath() is /root

My Json response for the tree looks like this:

{"status":{"status":0,"msg":"Ok","protocolversion":"extjs.json"},"value":{"name":"","path":"\/","type":"folder","leaf":false,"children":[{"name":"report_with_variables","path":"\/report_with_variables","type":"report","leaf":true,"title":"Report ohne Variablen","description":null},{"name":"subfolder1","path":"\/subfolder1","type":"folder","leaf":false},{"name":"subfolder2","path":"\/subfolder2","type":"folder","leaf":false},{"name":"subfolder3","path":"\/subfolder3","type":"folder","leaf":false},{"name":"testreports","path":"\/testreports","type":"folder","leaf":false}]}}
2

2 Answers

3
votes

expandPath works fine, try to verify the path you trying to expand. the path builds by default on node's model idProperty field, it is id property in the model data, maybe it is not the same as you are trying to use in the example.

  1. verify path and node's id
  2. try to run expandPath in the following format:

    tree.expandPath(path, null, null, function(success, node) { //analyse method execution
    });

    So you can analyse what is going on in the callback function:

    • if success is false and node is null then the path is empty

    • if success is false and node = root node than path is invalid in the very beginning

    • if success is false and node is not the root than the path is partially invalid

  3. try to get the path of some node in the tree using getPath() method and after it use obtained path with expandPath:

    var n = node.getPath(); tree.expandPath(path);

    it should work

0
votes

I had this same problem, and in my case the callback of expandPath was never called.

The reason was that the tree store was still loading a previous request when calling the expandPath method. Make sure your tree.store is not loading, before calling expandPath.

Maybe this helps you and/or others.