EXT textfield 添加鼠标事件

原文请参照:http://www.iteye.com/problems/66946

现有项目需要,对文本框添加鼠标事件,效果如图:


当鼠标移动到文本框上面时,会自动弹出文本框中的内容,

 items : [{

         xtype : 'textfield',
         fieldLabel : '指标',
         id : 'IndiName',
         name : 'IndiName',
         readOnly : true,
         anchor : '95%',
         selectOnFocus : true,
         listeners : {  
                render : updateTip,  
                //change : updateTip 
                focus:updateTip
          }  


}]

标颜色部分为给文本框添加的事件监听,调用的方法:

Ext.QuickTips.init();   
  
var updateTip = function(field){  
      if(field.rendered){  
            field.getEl().dom.setAttribute("ext:qtip", field.getValue());  
       }  
};  

其它注意:在这写的是当鼠标获取焦点的时候会触发updateTip事件 ,那么就需要输入数据或者在动态插入数据的时候将文本框焦点获取到,如下:

Ext.getCmp('IndiName').setValue(respText.modelColumn);

Ext.getCmp('IndiName').onFocus();

这样在动态赋值的时候就获取到了焦点

学习笔记暂记于此




你可能感兴趣的:(function,ext)