extjs 事件中设置scope访问上级组件的方法

extjs | 2019-09-13 10:02:39

extjs 事件中设置scope访问上级面板的方法:

Ext.define('app.menu.MenuTreeGridView',{
        extend: 'Ext.tree.Panel',
        alias: ['widget.menuTreeGridView'],
        closable:true,
        rootVisible:false,
        columnLines:true,
        tbar:[{
                text:"新增",
                icon:'images/icon/add.png'
        }],
        columns: [{
                xtype: 'treecolumn',
                text: '菜单名称',
                sortable:false,
                dataIndex: 'text',
                width:200
        }],
        store:{
                root:{id:0}
        },
        scope:this,
        listeners:{
                itemexpand:function( node, eOpts ){
                        if(node.id==0)this.selModel.select(node.firstChild);//没有scope,this就不是treepanle面板了,就访问不到treepanel
                }
        }
});

没有scope,this就不是treepanle面板了,就访问不到treepanel

登录后即可回复 登录 | 注册
    
关注编程学问公众号