Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / Boolean.html
1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-grid.column.Boolean'>/**
2 </span> * @class Ext.grid.column.Boolean
3  * @extends Ext.grid.column.Column
4  * &lt;p&gt;A Column definition class which renders boolean data fields.  See the {@link Ext.grid.column.Column#xtype xtype}
5  * config option of {@link Ext.grid.column.Column} for more details.&lt;/p&gt;
6  *
7  * {@img Ext.grid.column.Boolean/Ext.grid.column.Boolean.png Ext.grid.column.Boolean grid column}
8  *
9  * ## Code
10  *     Ext.create('Ext.data.Store', {
11  *        storeId:'sampleStore',
12  *        fields:[
13  *            {name: 'framework', type: 'string'},
14  *            {name: 'rocks', type: 'boolean'}
15  *        ],
16  *        data:{'items':[
17  *            {&quot;framework&quot;:&quot;Ext JS 4&quot;, &quot;rocks&quot;:true},
18  *            {&quot;framework&quot;:&quot;Sencha Touch&quot;, &quot;rocks&quot;:true},
19  *            {&quot;framework&quot;:&quot;Ext GWT&quot;, &quot;rocks&quot;:true},            
20  *            {&quot;framework&quot;:&quot;Other Guys&quot;, &quot;rocks&quot;:false}            
21  *        ]},
22  *        proxy: {
23  *            type: 'memory',
24  *            reader: {
25  *                type: 'json',
26  *                root: 'items'
27  *            }
28  *        }
29  *     });
30  *     
31  *     Ext.create('Ext.grid.Panel', {
32  *         title: 'Boolean Column Demo',
33  *         store: Ext.data.StoreManager.lookup('sampleStore'),
34  *         columns: [
35  *             {text: 'Framework',  dataIndex: 'framework', flex: 1},
36  *             {
37  *                 xtype: 'booleancolumn', 
38  *                 text: 'Rocks',
39  *                 trueText: 'Yes',
40  *                 falseText: 'No', 
41  *                 dataIndex: 'rocks'}
42  *         ],
43  *         height: 200,
44  *         width: 400,
45  *         renderTo: Ext.getBody()
46  *     });
47  * 
48  * @xtype booleancolumn
49  */
50 Ext.define('Ext.grid.column.Boolean', {
51     extend: 'Ext.grid.column.Column',
52     alias: ['widget.booleancolumn'],
53     alternateClassName: 'Ext.grid.BooleanColumn',
54
55 <span id='Ext-grid.column.Boolean-cfg-trueText'>    /**
56 </span>     * @cfg {String} trueText
57      * The string returned by the renderer when the column value is not falsey (defaults to &lt;tt&gt;'true'&lt;/tt&gt;).
58      */
59     trueText: 'true',
60
61 <span id='Ext-grid.column.Boolean-cfg-falseText'>    /**
62 </span>     * @cfg {String} falseText
63      * The string returned by the renderer when the column value is falsey (but not undefined) (defaults to
64      * &lt;tt&gt;'false'&lt;/tt&gt;).
65      */
66     falseText: 'false',
67
68 <span id='Ext-grid.column.Boolean-cfg-undefinedText'>    /**
69 </span>     * @cfg {String} undefinedText
70      * The string returned by the renderer when the column value is undefined (defaults to &lt;tt&gt;'&amp;#160;'&lt;/tt&gt;).
71      */
72     undefinedText: '&amp;#160;',
73
74     constructor: function(cfg){
75         this.callParent(arguments);
76         var trueText      = this.trueText,
77             falseText     = this.falseText,
78             undefinedText = this.undefinedText;
79
80         this.renderer = function(value){
81             if(value === undefined){
82                 return undefinedText;
83             }
84             if(!value || value === 'false'){
85                 return falseText;
86             }
87             return trueText;
88         };
89     }
90 });</pre></pre></body></html>