ネストされたリストに検索バーを追加しようとしています。検索バーが追加され、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();
}
});