2012-07-31 142 views

回答

1

當我試圖創建一個Treegrid afetr在搜索字段中搜索某些內容(需要通過URL傳遞)時,我發現了一些奇怪的行爲。

如何我創建這裏的邏輯:

  1. 創建一個樹類rootVisible的:假和存儲:的MyStore
  2. 我的店裏有沒有代理{},我不得不從控制器
  3. 動態設置此
  4. 在店內自動加載:假在那裏
  5. 二手mystore.load()將數據加載到樹

請求去了2次 雖然我沒有根節點,但樹中的空白根節點。

我修正了它在以下方式...不確定笏擴大這是正確的。任何更好的解決方案,請分享

樹類(查看)

  Didn’t define any treestore inside tree view 
      rootVisible: false 

控制器

search: function(button){ 

      var searchText = this.getSearchField().value; 


      //created a store instance 

      var mystore = Ext.data.StoreManager.lookup('MyTreeStore'); 

      mystore.setProxy({ 
           type: 'ajax', 
           url: 'app/searchid/'+searchText; 
          }); 


      var mytree = Ext.create('AM.view.MyTree',{store:mystore}); 

      Ext.getCmp('tn').add(mytree); 

      //DON’T USE store.load() method As we have set rootVisible: false so it will automatically try to load the store or will send the request 

}

存儲文件

  Ext.define('AM.store.BomTreeStore', { 

       extend: 'Ext.data.TreeStore', 

       model: 'AM.model.BomTree', 

       autoLoad: false, 

       folderSort: true 
      }); 

任何更好的解決方案,這裏面plz s野兔:)