/*!
* Ext JS Library 3.3.1
* Copyright(c) 2006-2010 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
* --------------------------
* @note by howl
*/
/**
* @class Ext.grid.AbstractSelectionModel
* @extends Ext.util.Observable
* <Abstract base class for grid SelectionModels. It provides the interface that should be
* implemented by descendant classes. This class should not be directly instantiated.>
* 這是針對grid的選擇模型的抽象基類,它提供應該被子類實現的接口.這個類不能直接的被實例化
* @constructor
*/
Ext.grid.AbstractSelectionModel = Ext.extend(Ext.util.Observable, {
/**
* <The GridPanel for which this SelectionModel is handling selection. Read-only.>
* @type Object
* @property grid
*/
constructor : function(){
this.locked = false;
Ext.grid.AbstractSelectionModel.superclass.constructor.call(this);//調用其父類的構造方法
},
/** @ignore <Called by the grid automatically. Do not call directly.>
* 會被grid自動調用,不要人為直接調用
*/
init : function(grid){
this.grid = grid;
if(this.lockOnInit){
delete this.lockOnInit;
this.locked = false;
this.lock();
}
this.initEvents();
},
/**
* <Locks the selections.>
* 為選擇加鎖
*/
lock : function(){
if(!this.locked){
this.locked = true;
// <If the grid has been set, then the view is already initialized.>如果grid已經被設置了,那麼說明view已經被初始化了
var g = this.grid;
if(g){
g.getView().on({
scope: this,
beforerefresh: this.sortUnLock,
refresh: this.sortLock
});
}else{
this.lockOnInit = true;
}
}
},
// <set the lock states before and after a view refresh>在view刷新之前和之後設置鎖的狀態
sortLock : function() {
this.locked = true;
},
// <set the lock states before and after a view refresh>在view刷新之前和之後設置鎖的狀態
sortUnLock : function() {
this.locked = false;
},
/**
* <Unlocks the selections.>為選區解鎖
*/
unlock : function(){
if(this.locked){
this.locked = false;
var g = this.grid,
gv;
// <If the grid has been set, then the view is already initialized.>如果grid已經被設置,說明view已經初始化了
if(g){
gv = g.getView();
gv.un('beforerefresh', this.sortUnLock, this);
gv.un('refresh', this.sortLock, this);
}else{
delete this.lockOnInit;
}
}
},
/**
* <Returns true if the selections are locked.>如果選區被鎖定,返回true
* @return {Boolean}
*/
isLocked : function(){
return this.locked;
},
destroy: function(){
this.unlock();
this.purgeListeners();
}
});
})
解读extjs源码之AbstractSelectionModel.js
最新推荐文章于 2018-05-14 17:41:15 发布