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