2013-04-30 68 views
0

這裏是我的樹面板,我使用:ExtJS的 - 最好的方式在一個窗口中顯示一棵樹

var tree = Ext.create('Ext.tree.Panel', { 
       store: mystore, 
       rootVisible: false, 
       useArrows: true, 
       frame: true, 
       title: 'Organization Tree', 
       renderTo: 'org-filter-window', 
       width: 600, 
       height: 400, 
       dockedItems: [{ 
        xtype: 'toolbar', 
        items: [{ 
         text: 'Expand All', 
         handler: function() { 
          tree.expandAll(); 
         } 
        }, { 
         text: 'Collapse All', 
         handler: function() { 
          tree.collapseAll(); 
         } 
        }] 
       }] 
      }); 

,我有這個窗口

var orgWindow = Ext.create("Ext.Window", { 
     store: myStoe, 
     title: 'Organization Tree', 
     width: 600, 
     height: 400, 
     html: '<div id="org-filter-window"></div>' 
    }); 

不知道最好的方法是什麼在窗口內顯示一棵樹。正如你所看到的,我已經嘗試在window html內渲染樹面板,並且它可以正常工作,但我不確定這是否是首選方式。

版本:Ext JS的4.0.7

+1

也建議你閱讀文檔刪除renderTo: 'org-filter-window',,它明確地告訴你不要做這個:「如果Component是一個容器的子項,那麼不要使用這個選項,容器的佈局管理器負責渲染和管理它的子項。」 – 2013-04-30 05:37:23

回答

2

如何:

var orgWindow = Ext.create("Ext.Window", { 
     store: myStoe, 
     title: 'Organization Tree', 
     width: 600, 
     height: 400, 
     items: tree // <--- the only change is here 
    }); 

,並從tree定義