3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
8 * @class Ext.list.Column
9 * <p>This class encapsulates column configuration data to be used in the initialization of a
10 * {@link Ext.list.ListView ListView}.</p>
11 * <p>While subclasses are provided to render data in different ways, this class renders a passed
12 * data field unchanged and is usually used for textual columns.</p>
14 Ext.list.Column = Ext.extend(Object, {
17 * @cfg {Boolean} isColumn
18 * Used by ListView constructor method to avoid reprocessing a Column
19 * if <code>isColumn</code> is not set ListView will recreate a new Ext.list.Column
26 * Set the CSS text-align property of the column. Defaults to <tt>'left'</tt>.
30 * @cfg {String} header Optional. The header text to be used as innerHTML
31 * (html tags are accepted) to display in the ListView. <b>Note</b>: to
32 * have a clickable header with no text displayed use <tt>' '</tt>.
37 * @cfg {Number} width Optional. Percentage of the container width
38 * this column should be allocated. Columns that have no width specified will be
39 * allocated with an equal percentage to fill 100% of the container width. To easily take
40 * advantage of the full container width, leave the width of at least one column undefined.
41 * Note that if you do not want to take up the full width of the container, the width of
42 * every column needs to be explicitly defined.
47 * @cfg {String} cls Optional. This option can be used to add a CSS class to the cell of each
48 * row for this column.
53 * @cfg {String} tpl Optional. Specify a string to pass as the
54 * configuration string for {@link Ext.XTemplate}. By default an {@link Ext.XTemplate}
55 * will be implicitly created using the <tt>dataIndex</tt>.
59 * @cfg {String} dataIndex <p><b>Required</b>. The name of the field in the
60 * ListViews's {@link Ext.data.Store}'s {@link Ext.data.Record} definition from
61 * which to draw the column's value.</p>
64 constructor : function(c){
66 c.tpl = new Ext.XTemplate('{' + c.dataIndex + '}');
68 else if(Ext.isString(c.tpl)){
69 c.tpl = new Ext.XTemplate(c.tpl);
76 Ext.reg('lvcolumn', Ext.list.Column);
79 * @class Ext.list.NumberColumn
80 * @extends Ext.list.Column
81 * <p>A Column definition class which renders a numeric data field according to a {@link #format} string. See the
82 * {@link Ext.list.Column#xtype xtype} config option of {@link Ext.list.Column} for more details.</p>
84 Ext.list.NumberColumn = Ext.extend(Ext.list.Column, {
86 * @cfg {String} format
87 * A formatting string as used by {@link Ext.util.Format#number} to format a numeric value for this Column
88 * (defaults to <tt>'0,000.00'</tt>).
92 constructor : function(c) {
93 c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':number("' + (c.format || this.format) + '")}');
94 Ext.list.NumberColumn.superclass.constructor.call(this, c);
98 Ext.reg('lvnumbercolumn', Ext.list.NumberColumn);
101 * @class Ext.list.DateColumn
102 * @extends Ext.list.Column
103 * <p>A Column definition class which renders a passed date according to the default locale, or a configured
104 * {@link #format}. See the {@link Ext.list.Column#xtype xtype} config option of {@link Ext.list.Column}
105 * for more details.</p>
107 Ext.list.DateColumn = Ext.extend(Ext.list.Column, {
109 constructor : function(c) {
110 c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':date("' + (c.format || this.format) + '")}');
111 Ext.list.DateColumn.superclass.constructor.call(this, c);
114 Ext.reg('lvdatecolumn', Ext.list.DateColumn);
117 * @class Ext.list.BooleanColumn
118 * @extends Ext.list.Column
119 * <p>A Column definition class which renders boolean data fields. See the {@link Ext.list.Column#xtype xtype}
120 * config option of {@link Ext.list.Column} for more details.</p>
122 Ext.list.BooleanColumn = Ext.extend(Ext.list.Column, {
124 * @cfg {String} trueText
125 * The string returned by the renderer when the column value is not falsey (defaults to <tt>'true'</tt>).
129 * @cfg {String} falseText
130 * The string returned by the renderer when the column value is falsey (but not undefined) (defaults to
135 * @cfg {String} undefinedText
136 * The string returned by the renderer when the column value is undefined (defaults to <tt>' '</tt>).
138 undefinedText: ' ',
140 constructor : function(c) {
141 c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
143 var t = this.trueText, f = this.falseText, u = this.undefinedText;
144 c.tpl.format = function(v){
148 if(!v || v === 'false'){
154 Ext.list.DateColumn.superclass.constructor.call(this, c);
158 Ext.reg('lvbooleancolumn', Ext.list.BooleanColumn);