2012-09-29 181 views
1

我想添加一個搜索欄到嵌套列表。 搜索欄添加和工作正常,當我嘗試使用console.log 它找到我的記錄,我正在尋找,但我不知道如何「刷新」嵌套列表,以便只顯示搜索結果。如果我使用「mystore.load()」,它會將我帶回根節點。如何搜索嵌套列表

Ext.define('Sencha.controller.FileList', { 
     extend: 'Ext.app.Controller', 
     requires: [ 
        'Ext.MessageBox' 
        ], 
config: { 
     refs: { 
      homeBtn: 'button[iconCls=home]', 
      searchField: 'searchbar' 
     }, 

     control: { 
      'button[iconCls=home]': { 
       tap: 'onbtnHomeTap' 
      }, 
      'searchField' : { 
        action : 'onKeyUp' 
      }   
     } 
}, 



     onbtnHomeTap: function() { 
     console.log('bthome tapped'); 
     //reloads the list! 
      Ext.getCmp('myList').getStore().load(); 
     console.log(Ext.getCmp('searchfield').getValue()); 
     }, 
     onKeyUp: function(field) { 
       console.log('inside searchbar_event'); 
       /* this.doFilter({ 
        q: field.getValue() 
       });*/ 

      Ext.getStore('NestedListStore').findRecord('text', field.getValue()); 

     }, 

     /** 
     * @private 
     * Listener for the 'filter' event fired by the listView set up in the 'list' action. This simply 
     * gets the form values that the user wants to filter on and tells the Store to filter using them. 
     */ 
     doFilter: function(values) { 
     var store = Ext.getStore('NestedListStore'), 
     filters = []; 

     Ext.iterate(values, function(field, value) { 
        filters.push({ 
           property: field, 
           value : value 
           }); 
        }); 

     store.clearFilter(); 
     store.filter(filters); 
     store.load(); 
     } 
}); 

回答

1

好的人,我回答我自己的問題:

簡單

Ext.getCmp('yourNestedListID').goToNode(Ext.getStore('NestedListStore').findRecord('text', field.getValue())); 

的伎倆 希望這可以幫助別人。

+0

謝謝!像魅力一樣工作! – LeoSarena