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">Ext.ns('Ext.ux.grid');
\r
10 <div id="cls-Ext.ux.grid.CheckColumn"></div>/**
\r
11 * @class Ext.ux.grid.CheckColumn
\r
13 * GridPanel plugin to add a column with check boxes to a grid.
\r
14 * <p>Example usage:</p>
\r
16 // create the column
\r
17 var checkColumn = new Ext.grid.CheckColumn({
\r
19 dataIndex: 'indoor',
\r
24 // add the column to the column model
\r
25 var cm = new Ext.grid.ColumnModel([{
\r
33 var grid = new Ext.grid.EditorGridPanel({
\r
36 plugins: [checkColumn], // include plugin
\r
40 * In addition to storing a Boolean value within the record data, this
\r
41 * class toggles a css class between <tt>'x-grid3-check-col'</tt> and
\r
42 * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
\r
45 Ext.ux.grid.CheckColumn = function(config){
\r
46 Ext.apply(this, config);
\r
50 this.renderer = this.renderer.createDelegate(this);
\r
53 Ext.ux.grid.CheckColumn.prototype ={
\r
54 init : function(grid){
\r
56 this.grid.on('render', function(){
\r
57 var view = this.grid.getView();
\r
58 view.mainBody.on('mousedown', this.onMouseDown, this);
\r
62 onMouseDown : function(e, t){
\r
63 if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
\r
65 var index = this.grid.getView().findRowIndex(t);
\r
66 var record = this.grid.store.getAt(index);
\r
67 record.set(this.dataIndex, !record.data[this.dataIndex]);
\r
71 renderer : function(v, p, record){
\r
72 p.css += ' x-grid3-check-col-td';
\r
73 return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
\r
78 Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);
\r
81 Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;</pre>
\r