如何在extjs中获取当前按钮`id?

Meh*_*nai 2 extjs extjs4

我们假设我有这个简单的按钮:

{
   xtype :'button',
   text :'button',
   id:'address'+counter.no,
   handler : function() {}
}
Run Code Online (Sandbox Code Playgroud)

如何访问当前按钮并访问其属性(如name,id等)?

我知道Ext.getCmp('compid')但我需要访问CURRENT按钮,我不知道它id.

enr*_*cog 5

你的意思是处理程序功能吗?

请参阅描述中的文档handler.
this传递第一个参数按钮对象时,您可以执行以下操作:

{
   xtype :'button',
   text :'button',
   id:'address'+counter.no,
   handler : function(thisButton, eventObject) {
       //Do something with thisButton like:
       alert(thisButton.getId());
   }
}
Run Code Online (Sandbox Code Playgroud)