Search code examples
javascriptextjsextjs3treepanel

Ext JS 3: How to copy a dynamically-generated treepanel?


I have a dynamically-generated Ext.tree.TreePanel in Ext 3.3.1. It looks like this:

-root
    -fruit
        -apple
    -vegetable
        -carrot

I need to make a duplicate/copy of this tree. I understand that the ids will be different and that's fine, but I want the text and the structure to be the same.

My current idea is to recursively go through and node-by-node create a new tree. Is there a faster way? NOTE: Someone very helpfully suggested cloneConfig(), but my understanding is that it will not capture a dynamically-generated tree. Is this confusion on my part?

Thanks for your time.


Solution

  • You can make a clone of any ExtJS component's configuration using cloneConfig() function.

    See the Ext.Component documentation: http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Component-method-cloneConfig