解决方案 »

  1.   

    Ext.select('input[id^=radio]').on('focus', function(ev) {
            console.log(ev.target.boxLabel);
        });
      

  2.   

    Ext.select('input[id^=radio]')得到的组件是在原始的dom对象生成的,和原来的radio这个组件不一样。。你可以直接这样绑定    panel.items.on('focus', function(radio, e, eOpts) {
            console.log(radio.boxLabel);
        });
      

  3.   

    Ext.select('input[id^=radio]') 你请看下 extjs的官方API 它返回的是Ext.dom.Element 而不是 Ext组件 而你创建的是ext组件他们2个不是同一个对象,
      

  4.   

    回版主大哥,您说的这么绑就不是undefined了,直接就么有反应呀
      

  5.   

    骚噶,也就是说绑定函数里传进来的已经不是Component了啊
      

  6.   

    我这里直接on好像增加不上事件,要each来添加
    anel.items.each(function () { this.on('focus', function () {console.log(this) }); })
      

  7.   

    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="./ExtJS4/resources/css/ext-all.css" />
    <script type="text/javascript" src="./ExtJS4/ext-all.js"></script>
    <script type="text/javascript">
    Ext.onReady(function() {
    var panel = new Ext.Panel({
    renderTo : 'panel',
    frame : true,
    width : 80,
    height : 120,
    title : 'Radio',
    items : [ {
    id : 'radio1',
    xtype : 'radio',
    boxLabel : '选项一',
    name : 'radio',
    inputValue : '1',
    checked : true
    }, {
    id : 'radio2',
    xtype : 'radio',
    boxLabel : '选项二',
    name : 'radio',
    inputValue : '2'
    }, {
    id : 'radio3',
    xtype : 'radio',
    boxLabel : '选项三',
    name : 'radio',
    inputValue : '3'
    } ]
    });
    Ext.select('input[id^=radio]').on('focus', function(radio, e, eOpts) {
        console.log(radio.target instanceof Ext.Component);
        console.log(radio.target instanceof Ext.dom.Element);
        console.log(radio.target instanceof Ext.CompositeElement);
    console.log(radio.boxLabel);
    });
    });
    </script>
    </head>
    <body>
    <div id="panel"></div>
    </body>
    </html>上面大哥说select返回的是Element类型,我查API说的是Ext.CompositeElement类型,但是我上面的例子输出的是
    false
    false
    false
    undefined 
    所以我也弄不清传入监听函数里的是什么类型了
      

  8.   

    Ext.select('input[id^=radio]')得到的对象添加事件参数已经不是Ext的radio对象看了下源代码,这样获取到的参数是通过http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.EventManager-method-on添加的,对应的参数为handler : Function
    The handler function the event invokes.Parameters
    event : Ext.EventObject
    The EventObject describing the event.
    target : Ext.dom.Element
    The Element which was the target of the event. Note that this may be filtered by using the delegate option.
    options : Object
    The options object from the addListener call.
    Ext不怎么用,都是活学活用。。        Ext.select('input[id^=radio]').on('focus', function (event, target, options) {
                //event为事件对象
                alert(target == this)//target和this为同一个对象,为DOM对象,因为是直接从dom对象生成的Ext对象
            });
      

  9.   

    http://docs.sencha.com/extjs/4.1.3/source/CompositeElementLite.html#Ext-dom-CompositeElementLite    // fixes scope with flyweight
        addListener: function(eventName, handler, scope, opt) {
            var els = this.elements,
                    len = els.length,
                    i, e;        for (i = 0; i < len; i++) {
                e = els[i];
                if (e) {
                    Ext.EventManager.on(e, eventName, handler, scope || e, opt);////////////
                }
            }
            return this;
        }
      

  10.   

    EXT的API还是不太完善,Ext.CompositeElement对象有提供on方法,但是API里面没有,只能找源代码来看了,对应的类源代码没找到可以再找基类