2 * @class Ext.ux.CheckColumn
3 * @extends Ext.grid.column.Column
4 * <p>A Header subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.</p>
5 * <p><b>Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel.</b></p>
6 * <p>Example usage:</p>
9 var grid = Ext.create('Ext.grid.Panel', {
24 * In addition to toggling a Boolean value within the record data, this
25 * class adds or removes a css class <tt>'x-grid-checked'</tt> on the td
26 * based on whether or not it is checked to alter the background image used
29 Ext.define('Ext.ux.CheckColumn', {
30 extend: 'Ext.grid.column.Column',
31 alias: 'widget.checkcolumn',
33 constructor: function() {
37 * Fires when the checked state of a row changes
38 * @param {Ext.ux.CheckColumn} this
39 * @param {Number} rowIndex The row index
40 * @param {Boolean} checked True if the box is checked
44 this.callParent(arguments);
49 * Process and refire events routed from the GridView's processEvent method.
51 processEvent: function(type, view, cell, recordIndex, cellIndex, e) {
52 if (type == 'mousedown' || (type == 'keydown' && (e.getKey() == e.ENTER || e.getKey() == e.SPACE))) {
53 var record = view.panel.store.getAt(recordIndex),
54 dataIndex = this.dataIndex,
55 checked = !record.get(dataIndex);
57 record.set(dataIndex, checked);
58 this.fireEvent('checkchange', this, recordIndex, checked);
62 return this.callParent(arguments);
66 // Note: class names are not placed on the prototype bc renderer scope
67 // is not in the header.
68 renderer : function(value){
69 var cssPrefix = Ext.baseCSSPrefix,
70 cls = [cssPrefix + 'grid-checkheader'];
73 cls.push(cssPrefix + 'grid-checkheader-checked');
75 return '<div class="' + cls.join(' ') + '"> </div>';