1 if(!dojo._hasResource['dojox.grid._grid.selection']){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource['dojox.grid._grid.selection'] = true;
3 dojo.provide('dojox.grid._grid.selection');
5 dojo.declare("dojox.grid.selection",
9 // Manages row selection for grid. Owned by grid and used internally
10 // for selection. Override to implement custom selection.
12 constructor: function(inGrid){
22 onCanSelect: function(inIndex){
23 return this.grid.onCanSelect(inIndex);
26 onCanDeselect: function(inIndex){
27 return this.grid.onCanDeselect(inIndex);
30 onSelected: function(inIndex){
31 return this.grid.onSelected(inIndex);
34 onDeselected: function(inIndex){
35 return this.grid.onDeselected(inIndex);
38 //onSetSelected: function(inIndex, inSelect) { };
39 onChanging: function(){
42 onChanged: function(){
43 return this.grid.onSelectionChanged();
46 isSelected: function(inIndex){
47 return this.selected[inIndex];
50 getFirstSelected: function(){
51 for(var i=0, l=this.selected.length; i<l; i++){
59 getNextSelected: function(inPrev){
60 for(var i=inPrev+1, l=this.selected.length; i<l; i++){
68 getSelected: function(){
70 for(var i=0, l=this.selected.length; i<l; i++){
78 getSelectedCount: function(){
80 for(var i=0; i<this.selected.length; i++){
88 beginUpdate: function(){
89 if(this.updating == 0){
95 endUpdate: function(){
97 if(this.updating == 0){
102 select: function(inIndex){
103 this.unselectAll(inIndex);
104 this.addToSelection(inIndex);
107 addToSelection: function(inIndex){
108 inIndex = Number(inIndex);
109 if(this.selected[inIndex]){
110 this.selectedIndex = inIndex;
112 if(this.onCanSelect(inIndex) !== false){
113 this.selectedIndex = inIndex;
115 this.selected[inIndex] = true;
116 this.grid.onSelected(inIndex);
117 //this.onSelected(inIndex);
118 //this.onSetSelected(inIndex, true);
124 deselect: function(inIndex){
125 inIndex = Number(inIndex);
126 if(this.selectedIndex == inIndex){
127 this.selectedIndex = -1;
129 if(this.selected[inIndex]){
130 if(this.onCanDeselect(inIndex) === false){
134 delete this.selected[inIndex];
135 this.grid.onDeselected(inIndex);
136 //this.onDeselected(inIndex);
137 //this.onSetSelected(inIndex, false);
142 setSelected: function(inIndex, inSelect){
143 this[(inSelect ? 'addToSelection' : 'deselect')](inIndex);
146 toggleSelect: function(inIndex){
147 this.setSelected(inIndex, !this.selected[inIndex])
150 insert: function(inIndex){
151 this.selected.splice(inIndex, 0, false);
152 if(this.selectedIndex >= inIndex){
153 this.selectedIndex++;
157 remove: function(inIndex){
158 this.selected.splice(inIndex, 1);
159 if(this.selectedIndex >= inIndex){
160 this.selectedIndex--;
164 unselectAll: function(inExcept){
165 for(var i in this.selected){
166 if((i!=inExcept)&&(this.selected[i]===true)){
172 shiftSelect: function(inFrom, inTo){
173 var s = (inFrom >= 0 ? inFrom : inTo), e = inTo;
178 for(var i=s; i<=e; i++){
179 this.addToSelection(i);
183 clickSelect: function(inIndex, inCtrlKey, inShiftKey){
185 if(!this.multiSelect){
186 this.select(inIndex);
188 var lastSelected = this.selectedIndex;
190 this.unselectAll(inIndex);
193 this.shiftSelect(lastSelected, inIndex);
195 this.toggleSelect(inIndex);
197 this.addToSelection(inIndex)
203 clickSelectEvent: function(e){
204 this.clickSelect(e.rowIndex, e.ctrlKey, e.shiftKey);