When a tree loads it is stealing focus
I have a tree panel with a text field within the top toolbar. After keystrokes the tree is reloaded, but it is stealing focus away from the textbox
Here is my code:
Ext.define('search_tree', {
extend:'Ext.tree.Panel',
rootVisible:false,
autoScroll:true,
store:Ext.create('Ext.data.TreeStore', {
root:{
id:'node',
nodeType:'async'
},
proxy:{
actionMethods:{
'read':'POST'
},
type:'ajax',
url:'myurl'
}
}),
tbar:['Search:', {
xtype:'textfield',
id:'search_combo',
listeners:{
keyup:{buffer:150,fn:function(field, e) {
var val = this.getRawValue();
if(val.length != this.valueLength){
var thisTree = this.up('treepanel');
thisTree.store.getRootNode().removeAll();
//***************
//When this load finishes the focus is taken away
//From the text field :(
//***************
thisTree.store.load({params:{search_string:val}}); 开发者_如何转开发
}
}}
}
}]
});
One solution would be to add a callback to your params on store.load() to call focus on the text:
//***************
//When this load finishes the focus is taken away
//From the text field :(
//***************
thisTree.store.load({params:{
search_string:val,
callback: function() {
this.focus(); /*or Ext.getCmp('search_combo').focus() depending on scoping*/
}
}});
精彩评论