求教:Ext左侧accordion菜单点击无法触发事件

anyhow1234 2014-05-04
Ext.onReady(function () {
    Viewport();
});

function Viewport() {
    var viewport = Ext.create("Ext.container.Viewport", {
        layout: {
            type: 'border',
            padding: '5',
        },
        items: [{
            region: 'north',
            height: 50,
            border: false,
            margin: '0,0,0,0',
            bodyStyle: {
                        background: '#3992D4'
            },
            //url: fail.jsp
            //html: 'fail.jsp'
            html: '<p align="right">欢迎你:张三&nbsp;&nbsp;&nbsp;退出 </p>'
        }, {
            region: 'west',
            title: '平台导航',
            width: 250,
            stateId: 'statePanelExample',
            stateful: true,
            split: true,
            collapsible: true,
            padding:'0',
            layout: 'accordion',
            items: [
                {
                    title: '终端设备管理',
                    layout: 'fit',
                    items: [{
                        xtype: 'treepanel',
                        border: 0,
                        rootVisible: false,
                        root: {
                            expanded: true,
                            children: [
                            { id: '01', text: '终端设备管理111', leaf: true, href: '',
                            listeneres:{
                           'click': function(){//这里怎么都弹不出东西来
                               alert('你单击基本资料了 ');
                             }

                           }
                            },
                                { id: '02', text: '终端设备管理2', leaf: true, url: '#' },
                                { id: '03', text: '终端设备管理3', leaf: true, url: '#' }
                            ]
                        }
                    }]
                }, {
                    title: '监控设备管理',
                    layout: 'fit',
                    items: [{
                        xtype: 'treepanel',
                        border: 0,
                        rootVisible: false,
                        root: {
                            expanded: true,
                            children: [
                            { id: '01', text: '监控设备管理1', leaf: true, url: '#' },
                                { id: '02', text: '监控设备管理2', leaf: true, url: '#' },
                                { id: '03', text: '监控设备管理3', leaf: true, url: '#' }
                            ]
                        }
                    }]
                }, {
                    title: '消息管理',
                    layout: 'fit',
                    items: [{
                        xtype: 'treepanel',
                        border: 0,
                        rootVisible: false,
                        root: {
                            expanded: true,
                            children: [
                            { id: '01', text: '消息管理', leaf: true, url: '#' }
                            ]
                        }
                    }]
                },{
                    title: '系统管理',
                    layout: 'fit',
                    items: [{
                        xtype: 'treepanel',
                        border: 0,
                        rootVisible: false,
                        root: {
                            expanded: true,
                            children: [
                            { id: '01', text: '机构管理', leaf: true, url: '#' },
                            { id: '02', text: '部门管理', leaf: true, url: '#' },
                            { id: '03', text: '角色管理', leaf: true, url: '#' },
                            { id: '04', text: '人员管理', leaf: true, url: '#' }
                            ]
                        }
                    }]
                }
            ]
        }, {
            region: 'center',
            xtype: 'tabpanel',
            id: 'MainTabPanel',
            activeTab: 0,
            items: {
                title: '首页',
                //html: 'Welcome!',
                id: 'userPanel',
                autoLoad:{
                    url:'view/usermanagement/listUser.jsp',
                    scripts:true
                } 
            }
        }, {
            region: 'south',
            collapsible: false,
            bodyStyle: {
            background: '#3992D4'
        },
            html: '<p align="center">&copy 北京XX科技股份有限公司 </p>',
            split: false,
            height: 30
        }]
    });
}
抹掉想法 2014-05-05
两个问题: 1.你把事件绑定到了数据上,组件才有点击事件,数据怎么会有。。
           2.单词写错了 listeneres => listeners

把事件提到treepanel组件上就可以了:
xtype: 'treepanel', 
                        border: 0, 
                        rootVisible: false, 
						listeners:{ 
							'select': function(rowModel, record, index, eOpts){
							   alert('你单击了' + record.data.text);
							}, 
							'itemclick': function(view, record, item, index, e, eOpts){
								alert('你单击了' + record.data.text);
							} 
					    },
                        root: { 
                            expanded: true, 
                            children: [ 
								{ id: '01', text: '终端设备管理111', leaf: true, href: ''}, 
                                { id: '02', text: '终端设备管理2', leaf: true, url: '#' }, 
                                { id: '03', text: '终端设备管理3', leaf: true, url: '#' } 
                            ] 
                        } 


两个事件select、itemclick随便选一个
Global site tag (gtag.js) - Google Analytics