2011-05-11 3 views
0

J'ai un panneau d'arborescence avec un champ de texte dans la barre d'outils supérieure. Après les frappes de l'arbre est rechargé, mais il est en train de voler attention loin de la zone de texteLorsqu'un arbre se charge, il vole le focus

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

    }] 
}); 

Répondre

0

Une solution serait d'ajouter un rappel à votre params sur store.load() à appeler l'accent sur le texte:

//*************** 
//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*/ 
    } 
}});              
+0

Cette solution fonctionne, sauf il y a environ une seconde période où il perd le focus, le rendant presque impossible de taper un travail complet avec précision :(Merci pour la réponse que – neolaser

Questions connexes