Upgrade to ExtJS 3.3.1 - Released 11/30/2010
[extjs.git] / docs / source / AbstractSelectionModel.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.3.1
11  * Copyright(c) 2006-2010 Sencha Inc.
12  * licensing@sencha.com
13  * http://www.sencha.com/license
14  */
15 <div id="cls-Ext.grid.AbstractSelectionModel"></div>/**
16  * @class Ext.grid.AbstractSelectionModel
17  * @extends Ext.util.Observable
18  * Abstract base class for grid SelectionModels.  It provides the interface that should be
19  * implemented by descendant classes.  This class should not be directly instantiated.
20  * @constructor
21  */
22 Ext.grid.AbstractSelectionModel = Ext.extend(Ext.util.Observable,  {
23     <div id="prop-Ext.grid.AbstractSelectionModel-grid"></div>/**
24      * The GridPanel for which this SelectionModel is handling selection. Read-only.
25      * @type Object
26      * @property grid
27      */
28
29     constructor : function(){
30         this.locked = false;
31         Ext.grid.AbstractSelectionModel.superclass.constructor.call(this);
32     },
33
34     /** @ignore Called by the grid automatically. Do not call directly. */
35     init : function(grid){
36         this.grid = grid;
37         if(this.lockOnInit){
38             delete this.lockOnInit;
39             this.locked = false;
40             this.lock();
41         }
42         this.initEvents();
43     },
44
45     <div id="method-Ext.grid.AbstractSelectionModel-lock"></div>/**
46      * Locks the selections.
47      */
48     lock : function(){
49         if(!this.locked){
50             this.locked = true;
51             // If the grid has been set, then the view is already initialized.
52             var g = this.grid;
53             if(g){
54                 g.getView().on({
55                     scope: this,
56                     beforerefresh: this.sortUnLock,
57                     refresh: this.sortLock
58                 });
59             }else{
60                 this.lockOnInit = true;
61             }
62         }
63     },
64
65     // set the lock states before and after a view refresh
66     sortLock : function() {
67         this.locked = true;
68     },
69
70     // set the lock states before and after a view refresh
71     sortUnLock : function() {
72         this.locked = false;
73     },
74
75     <div id="method-Ext.grid.AbstractSelectionModel-unlock"></div>/**
76      * Unlocks the selections.
77      */
78     unlock : function(){
79         if(this.locked){
80             this.locked = false;
81             var g = this.grid,
82                 gv;
83                 
84             // If the grid has been set, then the view is already initialized.
85             if(g){
86                 gv = g.getView();
87                 gv.un('beforerefresh', this.sortUnLock, this);
88                 gv.un('refresh', this.sortLock, this);    
89             }else{
90                 delete this.lockOnInit;
91             }
92         }
93     },
94
95     <div id="method-Ext.grid.AbstractSelectionModel-isLocked"></div>/**
96      * Returns true if the selections are locked.
97      * @return {Boolean}
98      */
99     isLocked : function(){
100         return this.locked;
101     },
102
103     destroy: function(){
104         this.unlock();
105         this.purgeListeners();
106     }
107 });</pre>    
108 </body>
109 </html>