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>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.grid.CheckboxSelectionModel"></div>/**
16 * @class Ext.grid.CheckboxSelectionModel
17 * @extends Ext.grid.RowSelectionModel
18 * A custom selection model that renders a column of checkboxes that can be toggled to select or deselect rows.
20 * @param {Object} config The configuration options
22 Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
24 <div id="cfg-Ext.grid.CheckboxSelectionModel-checkOnly"></div>/**
25 * @cfg {Boolean} checkOnly <tt>true</tt> if rows can only be selected by clicking on the
26 * checkbox column (defaults to <tt>false</tt>).
28 <div id="cfg-Ext.grid.CheckboxSelectionModel-header"></div>/**
29 * @cfg {String} header Any valid text or HTML fragment to display in the header cell for the
30 * checkbox column. Defaults to:<pre><code>
31 * '<div class="x-grid3-hd-checker">&#160;</div>'</tt>
33 * The default CSS class of <tt>'x-grid3-hd-checker'</tt> displays a checkbox in the header
34 * and provides support for automatic check all/none behavior on header click. This string
35 * can be replaced by any valid HTML fragment, including a simple text string (e.g.,
36 * <tt>'Select Rows'</tt>), but the automatic check all/none behavior will only work if the
37 * <tt>'x-grid3-hd-checker'</tt> class is supplied.
39 header : '<div class="x-grid3-hd-checker"> </div>',
40 <div id="cfg-Ext.grid.CheckboxSelectionModel-width"></div>/**
41 * @cfg {Number} width The default width in pixels of the checkbox column (defaults to <tt>20</tt>).
44 <div id="cfg-Ext.grid.CheckboxSelectionModel-sortable"></div>/**
45 * @cfg {Boolean} sortable <tt>true</tt> if the checkbox column is sortable (defaults to
57 constructor : function(){
58 Ext.grid.CheckboxSelectionModel.superclass.constructor.apply(this, arguments);
61 this.handleMouseDown = Ext.emptyFn;
66 initEvents : function(){
67 Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
68 this.grid.on('render', function(){
69 var view = this.grid.getView();
70 view.mainBody.on('mousedown', this.onMouseDown, this);
71 Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
76 // If handleMouseDown was called from another event (enableDragDrop), set a flag so
77 // onMouseDown does not process it a second time
78 handleMouseDown : function() {
79 Ext.grid.CheckboxSelectionModel.superclass.handleMouseDown.apply(this, arguments);
80 this.mouseHandled = true;
84 onMouseDown : function(e, t){
85 if(e.button === 0 && t.className == 'x-grid3-row-checker'){ // Only fire if left-click
87 var row = e.getTarget('.x-grid3-row');
89 // mouseHandled flag check for a duplicate selection (handleMouseDown) call
90 if(!this.mouseHandled && row){
91 var index = row.rowIndex;
92 if(this.isSelected(index)){
93 this.deselectRow(index);
95 this.selectRow(index, true);
99 this.mouseHandled = false;
103 onHdMouseDown : function(e, t){
104 if(t.className == 'x-grid3-hd-checker'){
106 var hd = Ext.fly(t.parentNode);
107 var isChecked = hd.hasClass('x-grid3-hd-checker-on');
109 hd.removeClass('x-grid3-hd-checker-on');
110 this.clearSelections();
112 hd.addClass('x-grid3-hd-checker-on');
119 renderer : function(v, p, record){
120 return '<div class="x-grid3-row-checker"> </div>';