3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.grid.CheckboxSelectionModel
11
* @extends Ext.grid.RowSelectionModel
12
* A custom selection model that renders a column of checkboxes that can be toggled to select or deselect rows.
14
* @param {Object} config The configuration options
16
Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
18
* @cfg {String} header Any valid text or HTML fragment to display in the header cell for the checkbox column
19
* (defaults to '<div class="x-grid3-hd-checker"> </div>'). The default CSS class of 'x-grid3-hd-checker'
20
* displays a checkbox in the header and provides support for automatic check all/none behavior on header click.
21
* This string can be replaced by any valid HTML fragment, including a simple text string (e.g., 'Select Rows'), but
22
* the automatic check all/none behavior will only work if the 'x-grid3-hd-checker' class is supplied.
24
header: '<div class="x-grid3-hd-checker"> </div>',
26
* @cfg {Number} width The default width in pixels of the checkbox column (defaults to 20).
30
* @cfg {Boolean} sortable True if the checkbox column is sortable (defaults to false).
41
initEvents : function(){
42
Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
43
this.grid.on('render', function(){
44
var view = this.grid.getView();
45
view.mainBody.on('mousedown', this.onMouseDown, this);
46
Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
52
onMouseDown : function(e, t){
53
if(e.button === 0 && t.className == 'x-grid3-row-checker'){ // Only fire if left-click
55
var row = e.getTarget('.x-grid3-row');
57
var index = row.rowIndex;
58
if(this.isSelected(index)){
59
this.deselectRow(index);
61
this.selectRow(index, true);
68
onHdMouseDown : function(e, t){
69
if(t.className == 'x-grid3-hd-checker'){
71
var hd = Ext.fly(t.parentNode);
72
var isChecked = hd.hasClass('x-grid3-hd-checker-on');
74
hd.removeClass('x-grid3-hd-checker-on');
75
this.clearSelections();
77
hd.addClass('x-grid3-hd-checker-on');
84
renderer : function(v, p, record){
85
return '<div class="x-grid3-row-checker"> </div>';
b'\\ No newline at end of file'