Upgrade to ExtJS 3.3.0 - Released 10/06/2010
[extjs.git] / docs / source / ColumnModel.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.3.0
11  * Copyright(c) 2006-2010 Ext JS, Inc.
12  * licensing@extjs.com
13  * http://www.extjs.com/license
14  */
15 <div id="cls-Ext.grid.ColumnModel"></div>/**
16  * @class Ext.grid.ColumnModel
17  * @extends Ext.util.Observable
18  * <p>After the data has been read into the client side cache (<b>{@link Ext.data.Store Store}</b>),
19  * the ColumnModel is used to configure how and what parts of that data will be displayed in the
20  * vertical slices (columns) of the grid. The Ext.grid.ColumnModel Class is the default implementation
21  * of a ColumnModel used by implentations of {@link Ext.grid.GridPanel GridPanel}.</p>
22  * <p>Data is mapped into the store's records and then indexed into the ColumnModel using the
23  * <tt>{@link Ext.grid.Column#dataIndex dataIndex}</tt>:</p>
24  * <pre><code>
25 {data source} == mapping ==> {data store} == <b><tt>{@link Ext.grid.Column#dataIndex dataIndex}</tt></b> ==> {ColumnModel}
26  * </code></pre>
27  * <p>Each {@link Ext.grid.Column Column} in the grid's ColumnModel is configured with a
28  * <tt>{@link Ext.grid.Column#dataIndex dataIndex}</tt> to specify how the data within
29  * each record in the store is indexed into the ColumnModel.</p>
30  * <p>There are two ways to initialize the ColumnModel class:</p>
31  * <p><u>Initialization Method 1: an Array</u></p>
32 <pre><code>
33  var colModel = new Ext.grid.ColumnModel([
34     { header: "Ticker", width: 60, sortable: true},
35     { header: "Company Name", width: 150, sortable: true, id: 'company'},
36     { header: "Market Cap.", width: 100, sortable: true},
37     { header: "$ Sales", width: 100, sortable: true, renderer: money},
38     { header: "Employees", width: 100, sortable: true, resizable: false}
39  ]);
40  </code></pre>
41  * <p>The ColumnModel may be initialized with an Array of {@link Ext.grid.Column} column configuration
42  * objects to define the initial layout / display of the columns in the Grid. The order of each
43  * {@link Ext.grid.Column} column configuration object within the specified Array defines the initial
44  * order of the column display.  A Column's display may be initially hidden using the
45  * <tt>{@link Ext.grid.Column#hidden hidden}</tt></b> config property (and then shown using the column
46  * header menu).  Fields that are not included in the ColumnModel will not be displayable at all.</p>
47  * <p>How each column in the grid correlates (maps) to the {@link Ext.data.Record} field in the
48  * {@link Ext.data.Store Store} the column draws its data from is configured through the
49  * <b><tt>{@link Ext.grid.Column#dataIndex dataIndex}</tt></b>.  If the
50  * <b><tt>{@link Ext.grid.Column#dataIndex dataIndex}</tt></b> is not explicitly defined (as shown in the
51  * example above) it will use the column configuration's index in the Array as the index.</p>
52  * <p>See <b><tt>{@link Ext.grid.Column}</tt></b> for additional configuration options for each column.</p>
53  * <p><u>Initialization Method 2: an Object</u></p>
54  * <p>In order to use configuration options from <tt>Ext.grid.ColumnModel</tt>, an Object may be used to
55  * initialize the ColumnModel.  The column configuration Array will be specified in the <tt><b>{@link #columns}</b></tt>
56  * config property. The <tt><b>{@link #defaults}</b></tt> config property can be used to apply defaults
57  * for all columns, e.g.:</p><pre><code>
58  var colModel = new Ext.grid.ColumnModel({
59     columns: [
60         { header: "Ticker", width: 60, menuDisabled: false},
61         { header: "Company Name", width: 150, id: 'company'},
62         { header: "Market Cap."},
63         { header: "$ Sales", renderer: money},
64         { header: "Employees", resizable: false}
65     ],
66     defaults: {
67         sortable: true,
68         menuDisabled: true,
69         width: 100
70     },
71     listeners: {
72         {@link #hiddenchange}: function(cm, colIndex, hidden) {
73             saveConfig(colIndex, hidden);
74         }
75     }
76 });
77  </code></pre>
78  * <p>In both examples above, the ability to apply a CSS class to all cells in a column (including the
79  * header) is demonstrated through the use of the <b><tt>{@link Ext.grid.Column#id id}</tt></b> config
80  * option. This column could be styled by including the following css:</p><pre><code>
81  //add this css *after* the core css is loaded
82 .x-grid3-td-company {
83     color: red; // entire column will have red font
84 }
85 // modify the header row only, adding an icon to the column header
86 .x-grid3-hd-company {
87     background: transparent
88         url(../../resources/images/icons/silk/building.png)
89         no-repeat 3px 3px ! important;
90         padding-left:20px;
91 }
92  </code></pre>
93  * Note that the "Company Name" column could be specified as the
94  * <b><tt>{@link Ext.grid.GridPanel}.{@link Ext.grid.GridPanel#autoExpandColumn autoExpandColumn}</tt></b>.
95  * @constructor
96  * @param {Mixed} config Specify either an Array of {@link Ext.grid.Column} configuration objects or specify
97  * a configuration Object (see introductory section discussion utilizing Initialization Method 2 above).
98  */
99 Ext.grid.ColumnModel = Ext.extend(Ext.util.Observable, {
100     <div id="cfg-Ext.grid.ColumnModel-defaultWidth"></div>/**
101      * @cfg {Number} defaultWidth (optional) The width of columns which have no <tt>{@link #width}</tt>
102      * specified (defaults to <tt>100</tt>).  This property shall preferably be configured through the
103      * <tt><b>{@link #defaults}</b></tt> config property.
104      */
105     defaultWidth: 100,
106
107     <div id="cfg-Ext.grid.ColumnModel-defaultSortable"></div>/**
108      * @cfg {Boolean} defaultSortable (optional) Default sortable of columns which have no
109      * sortable specified (defaults to <tt>false</tt>).  This property shall preferably be configured
110      * through the <tt><b>{@link #defaults}</b></tt> config property.
111      */
112     defaultSortable: false,
113
114     <div id="cfg-Ext.grid.ColumnModel-columns"></div>/**
115      * @cfg {Array} columns An Array of object literals.  The config options defined by
116      * <b>{@link Ext.grid.Column}</b> are the options which may appear in the object literal for each
117      * individual column definition.
118      */
119
120     <div id="cfg-Ext.grid.ColumnModel-defaults"></div>/**
121      * @cfg {Object} defaults Object literal which will be used to apply {@link Ext.grid.Column}
122      * configuration options to all <tt><b>{@link #columns}</b></tt>.  Configuration options specified with
123      * individual {@link Ext.grid.Column column} configs will supersede these <tt><b>{@link #defaults}</b></tt>.
124      */
125
126     constructor : function(config) {
127         <div id="prop-Ext.grid.ColumnModel-config"></div>/**
128              * An Array of {@link Ext.grid.Column Column definition} objects representing the configuration
129              * of this ColumnModel.  See {@link Ext.grid.Column} for the configuration properties that may
130              * be specified.
131              * @property config
132              * @type Array
133              */
134             if (config.columns) {
135                 Ext.apply(this, config);
136                 this.setConfig(config.columns, true);
137             } else {
138                 this.setConfig(config, true);
139             }
140             
141             this.addEvents(
142                 <div id="event-Ext.grid.ColumnModel-widthchange"></div>/**
143                  * @event widthchange
144                  * Fires when the width of a column is programmaticially changed using
145                  * <code>{@link #setColumnWidth}</code>.
146                  * Note internal resizing suppresses the event from firing. See also
147                  * {@link Ext.grid.GridPanel}.<code>{@link #columnresize}</code>.
148                  * @param {ColumnModel} this
149                  * @param {Number} columnIndex The column index
150                  * @param {Number} newWidth The new width
151                  */
152                 "widthchange",
153                 
154                 <div id="event-Ext.grid.ColumnModel-headerchange"></div>/**
155                  * @event headerchange
156                  * Fires when the text of a header changes.
157                  * @param {ColumnModel} this
158                  * @param {Number} columnIndex The column index
159                  * @param {String} newText The new header text
160                  */
161                 "headerchange",
162                 
163                 <div id="event-Ext.grid.ColumnModel-hiddenchange"></div>/**
164                  * @event hiddenchange
165                  * Fires when a column is hidden or "unhidden".
166                  * @param {ColumnModel} this
167                  * @param {Number} columnIndex The column index
168                  * @param {Boolean} hidden true if hidden, false otherwise
169                  */
170                 "hiddenchange",
171                 
172                 <div id="event-Ext.grid.ColumnModel-columnmoved"></div>/**
173                  * @event columnmoved
174                  * Fires when a column is moved.
175                  * @param {ColumnModel} this
176                  * @param {Number} oldIndex
177                  * @param {Number} newIndex
178                  */
179                 "columnmoved",
180                 
181                 <div id="event-Ext.grid.ColumnModel-configchange"></div>/**
182                  * @event configchange
183                  * Fires when the configuration is changed
184                  * @param {ColumnModel} this
185                  */
186                 "configchange"
187             );
188             
189             Ext.grid.ColumnModel.superclass.constructor.call(this);
190     },
191
192     <div id="method-Ext.grid.ColumnModel-getColumnId"></div>/**
193      * Returns the id of the column at the specified index.
194      * @param {Number} index The column index
195      * @return {String} the id
196      */
197     getColumnId : function(index) {
198         return this.config[index].id;
199     },
200
201     getColumnAt : function(index) {
202         return this.config[index];
203     },
204
205     <div id="method-Ext.grid.ColumnModel-setConfig"></div>/**
206      * <p>Reconfigures this column model according to the passed Array of column definition objects.
207      * For a description of the individual properties of a column definition object, see the
208      * <a href="#Ext.grid.ColumnModel-configs">Config Options</a>.</p>
209      * <p>Causes the {@link #configchange} event to be fired. A {@link Ext.grid.GridPanel GridPanel}
210      * using this ColumnModel will listen for this event and refresh its UI automatically.</p>
211      * @param {Array} config Array of Column definition objects.
212      * @param {Boolean} initial Specify <tt>true</tt> to bypass cleanup which deletes the <tt>totalWidth</tt>
213      * and destroys existing editors.
214      */
215     setConfig : function(config, initial) {
216         var i, c, len;
217         
218         if (!initial) { // cleanup
219             delete this.totalWidth;
220             
221             for (i = 0, len = this.config.length; i < len; i++) {
222                 c = this.config[i];
223                 
224                 if (c.setEditor) {
225                     //check here, in case we have a special column like a CheckboxSelectionModel
226                     c.setEditor(null);
227                 }
228             }
229         }
230
231         // backward compatibility
232         this.defaults = Ext.apply({
233             width: this.defaultWidth,
234             sortable: this.defaultSortable
235         }, this.defaults);
236
237         this.config = config;
238         this.lookup = {};
239
240         for (i = 0, len = config.length; i < len; i++) {
241             c = Ext.applyIf(config[i], this.defaults);
242             
243             // if no id, create one using column's ordinal position
244             if (Ext.isEmpty(c.id)) {
245                 c.id = i;
246             }
247             
248             if (!c.isColumn) {
249                 var Cls = Ext.grid.Column.types[c.xtype || 'gridcolumn'];
250                 c = new Cls(c);
251                 config[i] = c;
252             }
253             
254             this.lookup[c.id] = c;
255         }
256         
257         if (!initial) {
258             this.fireEvent('configchange', this);
259         }
260     },
261
262     <div id="method-Ext.grid.ColumnModel-getColumnById"></div>/**
263      * Returns the column for a specified id.
264      * @param {String} id The column id
265      * @return {Object} the column
266      */
267     getColumnById : function(id) {
268         return this.lookup[id];
269     },
270
271     <div id="method-Ext.grid.ColumnModel-getIndexById"></div>/**
272      * Returns the index for a specified column id.
273      * @param {String} id The column id
274      * @return {Number} the index, or -1 if not found
275      */
276     getIndexById : function(id) {
277         for (var i = 0, len = this.config.length; i < len; i++) {
278             if (this.config[i].id == id) {
279                 return i;
280             }
281         }
282         return -1;
283     },
284
285     <div id="method-Ext.grid.ColumnModel-moveColumn"></div>/**
286      * Moves a column from one position to another.
287      * @param {Number} oldIndex The index of the column to move.
288      * @param {Number} newIndex The position at which to reinsert the coolumn.
289      */
290     moveColumn : function(oldIndex, newIndex) {
291         var config = this.config,
292             c      = config[oldIndex];
293             
294         config.splice(oldIndex, 1);
295         config.splice(newIndex, 0, c);
296         this.dataMap = null;
297         this.fireEvent("columnmoved", this, oldIndex, newIndex);
298     },
299
300     <div id="method-Ext.grid.ColumnModel-getColumnCount"></div>/**
301      * Returns the number of columns.
302      * @param {Boolean} visibleOnly Optional. Pass as true to only include visible columns.
303      * @return {Number}
304      */
305     getColumnCount : function(visibleOnly) {
306         var length = this.config.length,
307             c = 0,
308             i;
309         
310         if (visibleOnly === true) {
311             for (i = 0; i < length; i++) {
312                 if (!this.isHidden(i)) {
313                     c++;
314                 }
315             }
316             
317             return c;
318         }
319         
320         return length;
321     },
322
323     <div id="method-Ext.grid.ColumnModel-getColumnsBy"></div>/**
324      * Returns the column configs that return true by the passed function that is called
325      * with (columnConfig, index)
326 <pre><code>
327 // returns an array of column config objects for all hidden columns
328 var columns = grid.getColumnModel().getColumnsBy(function(c){
329   return c.hidden;
330 });
331 </code></pre>
332      * @param {Function} fn A function which, when passed a {@link Ext.grid.Column Column} object, must
333      * return <code>true</code> if the column is to be included in the returned Array.
334      * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function
335      * is executed. Defaults to this ColumnModel.
336      * @return {Array} result
337      */
338     getColumnsBy : function(fn, scope) {
339         var config = this.config,
340             length = config.length,
341             result = [],
342             i, c;
343             
344         for (i = 0; i < length; i++){
345             c = config[i];
346             
347             if (fn.call(scope || this, c, i) === true) {
348                 result[result.length] = c;
349             }
350         }
351         
352         return result;
353     },
354
355     <div id="method-Ext.grid.ColumnModel-isSortable"></div>/**
356      * Returns true if the specified column is sortable.
357      * @param {Number} col The column index
358      * @return {Boolean}
359      */
360     isSortable : function(col) {
361         return !!this.config[col].sortable;
362     },
363
364     <div id="method-Ext.grid.ColumnModel-isMenuDisabled"></div>/**
365      * Returns true if the specified column menu is disabled.
366      * @param {Number} col The column index
367      * @return {Boolean}
368      */
369     isMenuDisabled : function(col) {
370         return !!this.config[col].menuDisabled;
371     },
372
373     <div id="method-Ext.grid.ColumnModel-getRenderer"></div>/**
374      * Returns the rendering (formatting) function defined for the column.
375      * @param {Number} col The column index.
376      * @return {Function} The function used to render the cell. See {@link #setRenderer}.
377      */
378     getRenderer : function(col) {
379         return this.config[col].renderer || Ext.grid.ColumnModel.defaultRenderer;
380     },
381
382     getRendererScope : function(col) {
383         return this.config[col].scope;
384     },
385
386     <div id="method-Ext.grid.ColumnModel-setRenderer"></div>/**
387      * Sets the rendering (formatting) function for a column.  See {@link Ext.util.Format} for some
388      * default formatting functions.
389      * @param {Number} col The column index
390      * @param {Function} fn The function to use to process the cell's raw data
391      * to return HTML markup for the grid view. The render function is called with
392      * the following parameters:<ul>
393      * <li><b>value</b> : Object<p class="sub-desc">The data value for the cell.</p></li>
394      * <li><b>metadata</b> : Object<p class="sub-desc">An object in which you may set the following attributes:<ul>
395      * <li><b>css</b> : String<p class="sub-desc">A CSS class name to add to the cell's TD element.</p></li>
396      * <li><b>attr</b> : String<p class="sub-desc">An HTML attribute definition string to apply to the data container element <i>within</i> the table cell
397      * (e.g. 'style="color:red;"').</p></li></ul></p></li>
398      * <li><b>record</b> : Ext.data.record<p class="sub-desc">The {@link Ext.data.Record} from which the data was extracted.</p></li>
399      * <li><b>rowIndex</b> : Number<p class="sub-desc">Row index</p></li>
400      * <li><b>colIndex</b> : Number<p class="sub-desc">Column index</p></li>
401      * <li><b>store</b> : Ext.data.Store<p class="sub-desc">The {@link Ext.data.Store} object from which the Record was extracted.</p></li></ul>
402      */
403     setRenderer : function(col, fn) {
404         this.config[col].renderer = fn;
405     },
406
407     <div id="method-Ext.grid.ColumnModel-getColumnWidth"></div>/**
408      * Returns the width for the specified column.
409      * @param {Number} col The column index
410      * @return {Number}
411      */
412     getColumnWidth : function(col) {
413         var width = this.config[col].width;
414         if(typeof width != 'number'){
415             width = this.defaultWidth;
416         }
417         return width;
418     },
419
420     <div id="method-Ext.grid.ColumnModel-setColumnWidth"></div>/**
421      * Sets the width for a column.
422      * @param {Number} col The column index
423      * @param {Number} width The new width
424      * @param {Boolean} suppressEvent True to suppress firing the <code>{@link #widthchange}</code>
425      * event. Defaults to false.
426      */
427     setColumnWidth : function(col, width, suppressEvent) {
428         this.config[col].width = width;
429         this.totalWidth = null;
430         
431         if (!suppressEvent) {
432              this.fireEvent("widthchange", this, col, width);
433         }
434     },
435
436     <div id="method-Ext.grid.ColumnModel-getTotalWidth"></div>/**
437      * Returns the total width of all columns.
438      * @param {Boolean} includeHidden True to include hidden column widths
439      * @return {Number}
440      */
441     getTotalWidth : function(includeHidden) {
442         if (!this.totalWidth) {
443             this.totalWidth = 0;
444             for (var i = 0, len = this.config.length; i < len; i++) {
445                 if (includeHidden || !this.isHidden(i)) {
446                     this.totalWidth += this.getColumnWidth(i);
447                 }
448             }
449         }
450         return this.totalWidth;
451     },
452
453     <div id="method-Ext.grid.ColumnModel-getColumnHeader"></div>/**
454      * Returns the header for the specified column.
455      * @param {Number} col The column index
456      * @return {String}
457      */
458     getColumnHeader : function(col) {
459         return this.config[col].header;
460     },
461
462     <div id="method-Ext.grid.ColumnModel-setColumnHeader"></div>/**
463      * Sets the header for a column.
464      * @param {Number} col The column index
465      * @param {String} header The new header
466      */
467     setColumnHeader : function(col, header) {
468         this.config[col].header = header;
469         this.fireEvent("headerchange", this, col, header);
470     },
471
472     <div id="method-Ext.grid.ColumnModel-getColumnTooltip"></div>/**
473      * Returns the tooltip for the specified column.
474      * @param {Number} col The column index
475      * @return {String}
476      */
477     getColumnTooltip : function(col) {
478             return this.config[col].tooltip;
479     },
480     <div id="method-Ext.grid.ColumnModel-setColumnTooltip"></div>/**
481      * Sets the tooltip for a column.
482      * @param {Number} col The column index
483      * @param {String} tooltip The new tooltip
484      */
485     setColumnTooltip : function(col, tooltip) {
486             this.config[col].tooltip = tooltip;
487     },
488
489     <div id="method-Ext.grid.ColumnModel-getDataIndex"></div>/**
490      * Returns the dataIndex for the specified column.
491 <pre><code>
492 // Get field name for the column
493 var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
494 </code></pre>
495      * @param {Number} col The column index
496      * @return {String} The column's dataIndex
497      */
498     getDataIndex : function(col) {
499         return this.config[col].dataIndex;
500     },
501
502     <div id="method-Ext.grid.ColumnModel-setDataIndex"></div>/**
503      * Sets the dataIndex for a column.
504      * @param {Number} col The column index
505      * @param {String} dataIndex The new dataIndex
506      */
507     setDataIndex : function(col, dataIndex) {
508         this.config[col].dataIndex = dataIndex;
509     },
510
511     <div id="method-Ext.grid.ColumnModel-findColumnIndex"></div>/**
512      * Finds the index of the first matching column for the given dataIndex.
513      * @param {String} col The dataIndex to find
514      * @return {Number} The column index, or -1 if no match was found
515      */
516     findColumnIndex : function(dataIndex) {
517         var c = this.config;
518         for(var i = 0, len = c.length; i < len; i++){
519             if(c[i].dataIndex == dataIndex){
520                 return i;
521             }
522         }
523         return -1;
524     },
525
526     <div id="method-Ext.grid.ColumnModel-isCellEditable"></div>/**
527      * Returns true if the cell is editable.
528 <pre><code>
529 var store = new Ext.data.Store({...});
530 var colModel = new Ext.grid.ColumnModel({
531   columns: [...],
532   isCellEditable: function(col, row) {
533     var record = store.getAt(row);
534     if (record.get('readonly')) { // replace with your condition
535       return false;
536     }
537     return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
538   }
539 });
540 var grid = new Ext.grid.GridPanel({
541   store: store,
542   colModel: colModel,
543   ...
544 });
545 </code></pre>
546      * @param {Number} colIndex The column index
547      * @param {Number} rowIndex The row index
548      * @return {Boolean}
549      */
550     isCellEditable : function(colIndex, rowIndex) {
551         var c = this.config[colIndex],
552             ed = c.editable;
553
554         //force boolean
555         return !!(ed || (!Ext.isDefined(ed) && c.editor));
556     },
557
558     <div id="method-Ext.grid.ColumnModel-getCellEditor"></div>/**
559      * Returns the editor defined for the cell/column.
560      * @param {Number} colIndex The column index
561      * @param {Number} rowIndex The row index
562      * @return {Ext.Editor} The {@link Ext.Editor Editor} that was created to wrap
563      * the {@link Ext.form.Field Field} used to edit the cell.
564      */
565     getCellEditor : function(colIndex, rowIndex) {
566         return this.config[colIndex].getCellEditor(rowIndex);
567     },
568
569     <div id="method-Ext.grid.ColumnModel-setEditable"></div>/**
570      * Sets if a column is editable.
571      * @param {Number} col The column index
572      * @param {Boolean} editable True if the column is editable
573      */
574     setEditable : function(col, editable) {
575         this.config[col].editable = editable;
576     },
577
578     <div id="method-Ext.grid.ColumnModel-isHidden"></div>/**
579      * Returns <tt>true</tt> if the column is <code>{@link Ext.grid.Column#hidden hidden}</code>,
580      * <tt>false</tt> otherwise.
581      * @param {Number} colIndex The column index
582      * @return {Boolean}
583      */
584     isHidden : function(colIndex) {
585         return !!this.config[colIndex].hidden; // ensure returns boolean
586     },
587
588     <div id="method-Ext.grid.ColumnModel-isFixed"></div>/**
589      * Returns <tt>true</tt> if the column is <code>{@link Ext.grid.Column#fixed fixed}</code>,
590      * <tt>false</tt> otherwise.
591      * @param {Number} colIndex The column index
592      * @return {Boolean}
593      */
594     isFixed : function(colIndex) {
595         return !!this.config[colIndex].fixed;
596     },
597
598     <div id="method-Ext.grid.ColumnModel-isResizable"></div>/**
599      * Returns true if the column can be resized
600      * @return {Boolean}
601      */
602     isResizable : function(colIndex) {
603         return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
604     },
605     
606     <div id="method-Ext.grid.ColumnModel-setHidden"></div>/**
607      * Sets if a column is hidden.
608 <pre><code>
609 myGrid.getColumnModel().setHidden(0, true); // hide column 0 (0 = the first column).
610 </code></pre>
611      * @param {Number} colIndex The column index
612      * @param {Boolean} hidden True if the column is hidden
613      */
614     setHidden : function(colIndex, hidden) {
615         var c = this.config[colIndex];
616         if(c.hidden !== hidden){
617             c.hidden = hidden;
618             this.totalWidth = null;
619             this.fireEvent("hiddenchange", this, colIndex, hidden);
620         }
621     },
622
623     <div id="method-Ext.grid.ColumnModel-setEditor"></div>/**
624      * Sets the editor for a column and destroys the prior editor.
625      * @param {Number} col The column index
626      * @param {Object} editor The editor object
627      */
628     setEditor : function(col, editor) {
629         this.config[col].setEditor(editor);
630     },
631
632     <div id="method-Ext.grid.ColumnModel-destroy"></div>/**
633      * Destroys this column model by purging any event listeners. Destroys and dereferences all Columns.
634      */
635     destroy : function() {
636         var length = this.config.length,
637             i = 0;
638
639         for (; i < length; i++){
640             this.config[i].destroy(); // Column's destroy encapsulates all cleanup.
641         }
642         delete this.config;
643         delete this.lookup;
644         this.purgeListeners();
645     },
646
647     /**
648      * @private
649      * Setup any saved state for the column, ensures that defaults are applied.
650      */
651     setState : function(col, state) {
652         state = Ext.applyIf(state, this.defaults);
653         Ext.apply(this.config[col], state);
654     }
655 });
656
657 // private
658 Ext.grid.ColumnModel.defaultRenderer = function(value) {
659     if (typeof value == "string" && value.length < 1) {
660         return "&#160;";
661     }
662     return value;
663 };</pre>    
664 </body>
665 </html>