3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.grid.CheckboxSelectionModel"></div>/**
\r
9 * @class Ext.grid.CheckboxSelectionModel
\r
10 * @extends Ext.grid.RowSelectionModel
\r
11 * A custom selection model that renders a column of checkboxes that can be toggled to select or deselect rows.
\r
13 * @param {Object} config The configuration options
\r
15 Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
\r
17 <div id="cfg-Ext.grid.CheckboxSelectionModel-checkOnly"></div>/**
\r
18 * @cfg {Boolean} checkOnly <tt>true</tt> if rows can only be selected by clicking on the
\r
19 * checkbox column (defaults to <tt>false</tt>).
\r
21 <div id="cfg-Ext.grid.CheckboxSelectionModel-header"></div>/**
\r
22 * @cfg {String} header Any valid text or HTML fragment to display in the header cell for the
\r
23 * checkbox column. Defaults to:<pre><code>
\r
24 * '<div class="x-grid3-hd-checker">&#160;</div>'</tt>
\r
26 * The default CSS class of <tt>'x-grid3-hd-checker'</tt> displays a checkbox in the header
\r
27 * and provides support for automatic check all/none behavior on header click. This string
\r
28 * can be replaced by any valid HTML fragment, including a simple text string (e.g.,
\r
29 * <tt>'Select Rows'</tt>), but the automatic check all/none behavior will only work if the
\r
30 * <tt>'x-grid3-hd-checker'</tt> class is supplied.
\r
32 header: '<div class="x-grid3-hd-checker"> </div>',
\r
33 <div id="cfg-Ext.grid.CheckboxSelectionModel-width"></div>/**
\r
34 * @cfg {Number} width The default width in pixels of the checkbox column (defaults to <tt>20</tt>).
\r
37 <div id="cfg-Ext.grid.CheckboxSelectionModel-sortable"></div>/**
\r
38 * @cfg {Boolean} sortable <tt>true</tt> if the checkbox column is sortable (defaults to
\r
49 constructor: function(){
\r
50 Ext.grid.CheckboxSelectionModel.superclass.constructor.apply(this, arguments);
\r
53 this.handleMouseDown = Ext.emptyFn;
\r
58 initEvents : function(){
\r
59 Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
\r
60 this.grid.on('render', function(){
\r
61 var view = this.grid.getView();
\r
62 view.mainBody.on('mousedown', this.onMouseDown, this);
\r
63 Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
\r
69 onMouseDown : function(e, t){
\r
70 if(e.button === 0 && t.className == 'x-grid3-row-checker'){ // Only fire if left-click
\r
72 var row = e.getTarget('.x-grid3-row');
\r
74 var index = row.rowIndex;
\r
75 if(this.isSelected(index)){
\r
76 this.deselectRow(index);
\r
78 this.selectRow(index, true);
\r
85 onHdMouseDown : function(e, t){
\r
86 if(t.className == 'x-grid3-hd-checker'){
\r
88 var hd = Ext.fly(t.parentNode);
\r
89 var isChecked = hd.hasClass('x-grid3-hd-checker-on');
\r
91 hd.removeClass('x-grid3-hd-checker-on');
\r
92 this.clearSelections();
\r
94 hd.addClass('x-grid3-hd-checker-on');
\r
101 renderer : function(v, p, record){
\r
102 return '<div class="x-grid3-row-checker"> </div>';
\r