0

上部のツールバー内にテキストフィールドがあるツリーパネルがあります。キーストロークの後、ツリーは再ロードされますが、テキストボックスからフォーカスを奪っています

これが私のコードです:

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

    }]
});
4

1 に答える 1

0

1つの解決策は、store.load()のパラメーターにコールバックを追加して、テキストにフォーカスを呼び出すことです。

//***************
//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*/
    }
}});                                                    
于 2011-05-12T16:01:22.700 に答える