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();
       }
 });
4

1 回答 1

1

好的人们,我回答了我自己的问题:

一个简单的

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

成功了希望这对其他人有帮助。

于 2012-09-29T13:33:02.153 回答