Когда дерево загружается, оно крадет фокус - PullRequest
0 голосов
/ 11 мая 2011

У меня есть панель дерева с текстовым полем в верхней панели инструментов. После нажатия клавиш дерево перезагружается, но оно отнимает фокус от текстового поля

Вот мой код:

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

    }]
});

1 Ответ

0 голосов
/ 12 мая 2011

Одним из решений будет добавление обратного вызова к вашим параметрам в 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*/
    }
}});                                                    
...