Extjs 4如何获取父组件的ID?

Kun*_*nal 9 extjs4

我有多个fieldset.并且在Extjs 4中的每个字段集中都有Button.我想在按钮单击事件上获取字段集ID,以便我可以知道按钮被单击的字段集

我怎么得到这个?

    {
     xtype:'fieldset',
     id:'fs1',
     items:[{
     xtype:'button',
     id:'b1',
     handler:function(){
       // here i want to get fieldset's id because because fieldset and button were added dynamically.
      }
     }]
    }
Run Code Online (Sandbox Code Playgroud)

谢谢,库纳尔

  Actual Code:

  Ext.define('My.Group',{   
xtype : 'fieldset',
 config: {
     title:'Group' + i.toString(),
     id : '_group' + i.toString()       
 },
     constructor: function(config) {
     this.initConfig(config);

   return this;
 },

collapsible : true,
frame : false,
boder : false,
items : [ {
xtype : 'button',
text : 'Add KeyWord',
id: 'btn',
width : 100,
handler : function(button,event) {

     var fieldset = button.findParentByType('fieldset');
     var fieldsetsID = fieldset.getId();

    console.log(fieldset);

    Ext.getCmp(fieldsetId).insert(2, rangeField);
    Ext.getCmp(fieldsetsID).doLayout();
}

 }, {
 xtype : 'button',
 text : 'Add Range Type',
 width : 100
} ]
});
Run Code Online (Sandbox Code Playgroud)

我点击按钮调用此功能

 handler : function() {
        i=i+1;
        var group = new My.Group({
            title:'Group' + i.toString(),
            id : '_group' + i.toString()                
        });

        console.log(group);
        Ext.getCmp('_aspanel').insert(i, group);                
        Ext.getCmp('_aspanel').doLayout();  
Run Code Online (Sandbox Code Playgroud)

Zan*_*ngo 22

我已正确实现了处理程序.

{
    xtype:'fieldset',
    id:'fs1',
    items:[{
        xtype:'button',
        id:'b1',
        handler:function(btn){
            // Retrieve fieldset. 
            var fieldset = btn.up('fieldset');
            // Retrieve Id of fieldset.
            var fieldsetId = fieldset.getId();
        }
    }]
}

button.up("[xtype='fieldset']")


Mch*_*chl 5

Ext.onReady(function() {
  var panel = Ext.create('Ext.panel.Panel', {
      items:  {
        xtype:'fieldset',
        id:'fs1',
        items:[{
          xtype:'button',
          id:'b1',
          handler:function(b,e){
            var fieldset = b.findParentByType('fieldset');
            var fieldsetID = fieldset.getId();
            console.log(fieldsetID);
          }
        }]
      },
      renderTo: document.body
  });
});
Run Code Online (Sandbox Code Playgroud)

请注意,一旦有fieldset变量,您实际上可以直接将项添加到此容器,而无需使用其ID