define("dojox/grid/Selection", [ "dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang", "dojo/dom-attr" ], function(declare, array, lang, domAttr){ return declare("dojox.grid.Selection", null, { // summary: // Manages row selection for grid. Owned by grid and used internally // for selection. Override to implement custom selection. constructor: function(inGrid){ this.grid = inGrid; this.selected = []; this.setMode(inGrid.selectionMode); }, mode: 'extended', selected: null, updating: 0, selectedIndex: -1, setMode: function(mode){ if(this.selected.length){ this.deselectAll(); } if(mode != 'extended' && mode != 'multiple' && mode != 'single' && mode != 'none'){ this.mode = 'extended'; }else{ this.mode = mode; } }, onCanSelect: function(inIndex){ return this.grid.onCanSelect(inIndex); }, onCanDeselect: function(inIndex){ return this.grid.onCanDeselect(inIndex); }, onSelected: function(inIndex){ }, onDeselected: function(inIndex){ }, //onSetSelected: function(inIndex, inSelect) { }; onChanging: function(){ }, onChanged: function(){ }, isSelected: function(inIndex){ if(this.mode == 'none'){ return false; } return this.selected[inIndex]; }, getFirstSelected: function(){ if(!this.selected.length||this.mode == 'none'){ return -1; } for(var i=0, l=this.selected.length; i= 0 ? inFrom : inTo), e = inTo; if(s > e){ e = s; s = inTo; } for(var i=s; i<=e; i++){ func(i); } }, selectRange: function(inFrom, inTo){ this._range(inFrom, inTo, lang.hitch(this, "addToSelection")); }, deselectRange: function(inFrom, inTo){ this._range(inFrom, inTo, lang.hitch(this, "deselect")); }, insert: function(inIndex){ this.selected.splice(inIndex, 0, false); if(this.selectedIndex >= inIndex){ this.selectedIndex++; } }, remove: function(inIndex){ this.selected.splice(inIndex, 1); if(this.selectedIndex >= inIndex){ this.selectedIndex--; } }, deselectAll: function(inExcept){ for(var i in this.selected){ if((i!=inExcept)&&(this.selected[i]===true)){ this.deselect(i); } } }, clickSelect: function(inIndex, inCtrlKey, inShiftKey){ if(this.mode == 'none'){ return; } this._beginUpdate(); if(this.mode != 'extended'){ this.select(inIndex); }else{ var lastSelected = this.selectedIndex; if(!inCtrlKey){ this.deselectAll(inIndex); } if(inShiftKey){ this.selectRange(lastSelected, inIndex); }else if(inCtrlKey){ this.toggleSelect(inIndex); }else{ this.addToSelection(inIndex); } } this._endUpdate(); }, clickSelectEvent: function(e){ this.clickSelect(e.rowIndex, dojo.isCopyKey(e), e.shiftKey); }, clear: function(){ this._beginUpdate(); this.deselectAll(); this._endUpdate(); } }); });