Extjs scope作用域的用法

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

Extjs scope作用域的用法,方便的访问局部和外部变量


function newGrid(){        
        this.store = new Ext.data.Store({
                proxy : new Ext.data.HttpProxy({
                                url : url
                }),                        
                reader : reader        ,
                listeners : {
                        "load":function(store,records,option){
                                if(records.length>0)this.grid.selModel.selectFirstRow();//这里用this访问grid,如果没有下面的scope : this就访问不到
                        },
                        scope : this
                }
        });
         this.grid = new Ext.grid.GridPanel({
                cm:this.columnModel,
                store:this.store,
                region:'center',
                border:false,
                id:panelId,
                autoScroll:true,
                bbar:new Ext.PagingToolbar({store:this.store,pageSize:this.page,displayInfo:true})
        });
}


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