X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/2e847cf21b8ab9d15fa167b315ca5b2fa92638fc..c8256059947f3aa8f5b0a9a2acf55e2142bb4742:/src/widgets/grid/CheckboxSelectionModel.js?ds=inline
diff --git a/src/widgets/grid/CheckboxSelectionModel.js b/src/widgets/grid/CheckboxSelectionModel.js
index 7d37a18b..7e8d4be5 100644
--- a/src/widgets/grid/CheckboxSelectionModel.js
+++ b/src/widgets/grid/CheckboxSelectionModel.js
@@ -1,103 +1,115 @@
/*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
-/**
- * @class Ext.grid.CheckboxSelectionModel
- * @extends Ext.grid.RowSelectionModel
- * A custom selection model that renders a column of checkboxes that can be toggled to select or deselect rows.
- * @constructor
- * @param {Object} config The configuration options
- */
-Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
-
- /**
- * @cfg {Boolean} checkOnly true if rows can only be selected by clicking on the
- * checkbox column (defaults to false).
- */
- /**
- * @cfg {String} header Any valid text or HTML fragment to display in the header cell for the
- * checkbox column. Defaults to:
- * '<div class="x-grid3-hd-checker"> </div>'
- *
- * The default CSS class of 'x-grid3-hd-checker' displays a checkbox in the header
- * and provides support for automatic check all/none behavior on header click. This string
- * can be replaced by any valid HTML fragment, including a simple text string (e.g.,
- * 'Select Rows'), but the automatic check all/none behavior will only work if the
- * 'x-grid3-hd-checker' class is supplied.
- */
- header : '
',
- /**
- * @cfg {Number} width The default width in pixels of the checkbox column (defaults to 20).
- */
- width : 20,
- /**
- * @cfg {Boolean} sortable true if the checkbox column is sortable (defaults to
- * false).
- */
- sortable : false,
-
- // private
- menuDisabled : true,
- fixed : true,
- dataIndex : '',
- id : 'checker',
-
- constructor : function(){
- Ext.grid.CheckboxSelectionModel.superclass.constructor.apply(this, arguments);
-
- if(this.checkOnly){
- this.handleMouseDown = Ext.emptyFn;
- }
- },
-
- // private
- initEvents : function(){
- Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
- this.grid.on('render', function(){
- var view = this.grid.getView();
- view.mainBody.on('mousedown', this.onMouseDown, this);
- Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
-
- }, this);
- },
-
- // private
- onMouseDown : function(e, t){
- if(e.button === 0 && t.className == 'x-grid3-row-checker'){ // Only fire if left-click
- e.stopEvent();
- var row = e.getTarget('.x-grid3-row');
- if(row){
- var index = row.rowIndex;
- if(this.isSelected(index)){
- this.deselectRow(index);
- }else{
- this.selectRow(index, true);
- }
- }
- }
- },
-
- // private
- onHdMouseDown : function(e, t){
- if(t.className == 'x-grid3-hd-checker'){
- e.stopEvent();
- var hd = Ext.fly(t.parentNode);
- var isChecked = hd.hasClass('x-grid3-hd-checker-on');
- if(isChecked){
- hd.removeClass('x-grid3-hd-checker-on');
- this.clearSelections();
- }else{
- hd.addClass('x-grid3-hd-checker-on');
- this.selectAll();
- }
- }
- },
-
- // private
- renderer : function(v, p, record){
- return '
';
- }
+/**
+ * @class Ext.grid.CheckboxSelectionModel
+ * @extends Ext.grid.RowSelectionModel
+ * A custom selection model that renders a column of checkboxes that can be toggled to select or deselect rows.
+ * @constructor
+ * @param {Object} config The configuration options
+ */
+Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
+
+ /**
+ * @cfg {Boolean} checkOnly true if rows can only be selected by clicking on the
+ * checkbox column (defaults to false).
+ */
+ /**
+ * @cfg {String} header Any valid text or HTML fragment to display in the header cell for the
+ * checkbox column. Defaults to:
+ * '<div class="x-grid3-hd-checker"> </div>'
+ *
+ * The default CSS class of 'x-grid3-hd-checker' displays a checkbox in the header
+ * and provides support for automatic check all/none behavior on header click. This string
+ * can be replaced by any valid HTML fragment, including a simple text string (e.g.,
+ * 'Select Rows'), but the automatic check all/none behavior will only work if the
+ * 'x-grid3-hd-checker' class is supplied.
+ */
+ header : '
',
+ /**
+ * @cfg {Number} width The default width in pixels of the checkbox column (defaults to 20).
+ */
+ width : 20,
+ /**
+ * @cfg {Boolean} sortable true if the checkbox column is sortable (defaults to
+ * false).
+ */
+ sortable : false,
+
+ // private
+ menuDisabled : true,
+ fixed : true,
+ hideable: false,
+ dataIndex : '',
+ id : 'checker',
+
+ constructor : function(){
+ Ext.grid.CheckboxSelectionModel.superclass.constructor.apply(this, arguments);
+
+ if(this.checkOnly){
+ this.handleMouseDown = Ext.emptyFn;
+ }
+ },
+
+ // private
+ initEvents : function(){
+ Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
+ this.grid.on('render', function(){
+ var view = this.grid.getView();
+ view.mainBody.on('mousedown', this.onMouseDown, this);
+ Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
+
+ }, this);
+ },
+
+ // If handleMouseDown was called from another event (enableDragDrop), set a flag so
+ // onMouseDown does not process it a second time
+ handleMouseDown : function() {
+ Ext.grid.CheckboxSelectionModel.superclass.handleMouseDown.apply(this, arguments);
+ this.mouseHandled = true;
+ },
+
+ // private
+ onMouseDown : function(e, t){
+ if(e.button === 0 && t.className == 'x-grid3-row-checker'){ // Only fire if left-click
+ e.stopEvent();
+ var row = e.getTarget('.x-grid3-row');
+
+ // mouseHandled flag check for a duplicate selection (handleMouseDown) call
+ if(!this.mouseHandled && row){
+ var index = row.rowIndex;
+ if(this.isSelected(index)){
+ this.deselectRow(index);
+ }else{
+ this.selectRow(index, true);
+ this.grid.getView().focusRow(index);
+ }
+ }
+ }
+ this.mouseHandled = false;
+ },
+
+ // private
+ onHdMouseDown : function(e, t){
+ if(t.className == 'x-grid3-hd-checker'){
+ e.stopEvent();
+ var hd = Ext.fly(t.parentNode);
+ var isChecked = hd.hasClass('x-grid3-hd-checker-on');
+ if(isChecked){
+ hd.removeClass('x-grid3-hd-checker-on');
+ this.clearSelections();
+ }else{
+ hd.addClass('x-grid3-hd-checker-on');
+ this.selectAll();
+ }
+ }
+ },
+
+ // private
+ renderer : function(v, p, record){
+ return '
';
+ }
});
\ No newline at end of file