有时候需要这样的功能,比如做页面查询,有文本框,有按钮,为操作便捷,实现button查询的时候,也需要textfield回车查询
var btnSearch=new Ext.button({
text:'查询',
minWidth:'80',//设置按钮长度
handler: doSearch
})
new Ext.form.TextField({
fieldLabel : '用户名',
name : 'name',
id : 'name',
anchor : '80%',
enableKeyEvents:true,
initEvents:function(){
var keyPress=function(e){
if(e.getKey()==e.ENTER){
doSearch();
}
};
this.el.on("keypress",keyPress,this);
}
})
functiond doSearch(){
///查询方法
}