Extjs 4 How to get id of parent Component?

后端 未结 2 713
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-05 01:23

I have multiple fieldset. And have Button inside each fieldset in Extjs 4. I want to get fieldset id on the button click event, so that i can know from which fieldse

2条回答
  •  遥遥无期
    2021-01-05 01:43

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

    Notice, that once you have fieldset variable, you can actually add items to this container directly, without need to use its ID

提交回复
热议问题