2012-09-29 182 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