Upgrade to ExtJS 3.2.2 - Released 06/02/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.2.2
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     <div id="cfg-Ext.grid.ColumnModel-defaultSortable"></div>/**
107      * @cfg {Boolean} defaultSortable (optional) Default sortable of columns which have no
108      * sortable specified (defaults to <tt>false</tt>).  This property shall preferably be configured
109      * through the <tt><b>{@link #defaults}</b></tt> config property.
110      */
111     defaultSortable: false,
112     <div id="cfg-Ext.grid.ColumnModel-columns"></div>/**
113      * @cfg {Array} columns An Array of object literals.  The config options defined by
114      * <b>{@link Ext.grid.Column}</b> are the options which may appear in the object literal for each
115      * individual column definition.
116      */
117     <div id="cfg-Ext.grid.ColumnModel-defaults"></div>/**
118      * @cfg {Object} defaults Object literal which will be used to apply {@link Ext.grid.Column}
119      * configuration options to all <tt><b>{@link #columns}</b></tt>.  Configuration options specified with
120      * individual {@link Ext.grid.Column column} configs will supersede these <tt><b>{@link #defaults}</b></tt>.
121      */
122
123     constructor : function(config){
124         <div id="prop-Ext.grid.ColumnModel-config"></div>/**
125              * An Array of {@link Ext.grid.Column Column definition} objects representing the configuration
126              * of this ColumnModel.  See {@link Ext.grid.Column} for the configuration properties that may
127              * be specified.
128              * @property config
129              * @type Array
130              */
131             if(config.columns){
132                 Ext.apply(this, config);
133                 this.setConfig(config.columns, true);
134             }else{
135                 this.setConfig(config, true);
136             }
137             this.addEvents(
138                 <div id="event-Ext.grid.ColumnModel-widthchange"></div>/**
139                  * @event widthchange
140                  * Fires when the width of a column is programmaticially changed using
141                  * <code>{@link #setColumnWidth}</code>.
142                  * Note internal resizing suppresses the event from firing. See also
143                  * {@link Ext.grid.GridPanel}.<code>{@link #columnresize}</code>.
144                  * @param {ColumnModel} this
145                  * @param {Number} columnIndex The column index
146                  * @param {Number} newWidth The new width
147                  */
148                 "widthchange",
149                 <div id="event-Ext.grid.ColumnModel-headerchange"></div>/**
150                  * @event headerchange
151                  * Fires when the text of a header changes.
152                  * @param {ColumnModel} this
153                  * @param {Number} columnIndex The column index
154                  * @param {String} newText The new header text
155                  */
156                 "headerchange",
157                 <div id="event-Ext.grid.ColumnModel-hiddenchange"></div>/**
158                  * @event hiddenchange
159                  * Fires when a column is hidden or "unhidden".
160                  * @param {ColumnModel} this
161                  * @param {Number} columnIndex The column index
162                  * @param {Boolean} hidden true if hidden, false otherwise
163                  */
164                 "hiddenchange",
165                 <div id="event-Ext.grid.ColumnModel-columnmoved"></div>/**
166                  * @event columnmoved
167                  * Fires when a column is moved.
168                  * @param {ColumnModel} this
169                  * @param {Number} oldIndex
170                  * @param {Number} newIndex
171                  */
172                 "columnmoved",
173                 <div id="event-Ext.grid.ColumnModel-configchange"></div>/**
174                  * @event configchange
175                  * Fires when the configuration is changed
176                  * @param {ColumnModel} this
177                  */
178                 "configchange"
179             );
180             Ext.grid.ColumnModel.superclass.constructor.call(this);
181     },
182
183     <div id="method-Ext.grid.ColumnModel-getColumnId"></div>/**
184      * Returns the id of the column at the specified index.
185      * @param {Number} index The column index
186      * @return {String} the id
187      */
188     getColumnId : function(index){
189         return this.config[index].id;
190     },
191
192     getColumnAt : function(index){
193         return this.config[index];
194     },
195
196     <div id="method-Ext.grid.ColumnModel-setConfig"></div>/**
197      * <p>Reconfigures this column model according to the passed Array of column definition objects.
198      * For a description of the individual properties of a column definition object, see the
199      * <a href="#Ext.grid.ColumnModel-configs">Config Options</a>.</p>
200      * <p>Causes the {@link #configchange} event to be fired. A {@link Ext.grid.GridPanel GridPanel}
201      * using this ColumnModel will listen for this event and refresh its UI automatically.</p>
202      * @param {Array} config Array of Column definition objects.
203      * @param {Boolean} initial Specify <tt>true</tt> to bypass cleanup which deletes the <tt>totalWidth</tt>
204      * and destroys existing editors.
205      */
206     setConfig : function(config, initial){
207         var i, c, len;
208         if(!initial){ // cleanup
209             delete this.totalWidth;
210             for(i = 0, len = this.config.length; i < len; i++){
211                 c = this.config[i];
212                 if(c.setEditor){
213                     //check here, in case we have a special column like a CheckboxSelectionModel
214                     c.setEditor(null);
215                 }
216             }
217         }
218
219         // backward compatibility
220         this.defaults = Ext.apply({
221             width: this.defaultWidth,
222             sortable: this.defaultSortable
223         }, this.defaults);
224
225         this.config = config;
226         this.lookup = {};
227
228         for(i = 0, len = config.length; i < len; i++){
229             c = Ext.applyIf(config[i], this.defaults);
230             // if no id, create one using column's ordinal position
231             if(Ext.isEmpty(c.id)){
232                 c.id = i;
233             }
234             if(!c.isColumn){
235                 var Cls = Ext.grid.Column.types[c.xtype || 'gridcolumn'];
236                 c = new Cls(c);
237                 config[i] = c;
238             }
239             this.lookup[c.id] = c;
240         }
241         if(!initial){
242             this.fireEvent('configchange', this);
243         }
244     },
245
246     <div id="method-Ext.grid.ColumnModel-getColumnById"></div>/**
247      * Returns the column for a specified id.
248      * @param {String} id The column id
249      * @return {Object} the column
250      */
251     getColumnById : function(id){
252         return this.lookup[id];
253     },
254
255     <div id="method-Ext.grid.ColumnModel-getIndexById"></div>/**
256      * Returns the index for a specified column id.
257      * @param {String} id The column id
258      * @return {Number} the index, or -1 if not found
259      */
260     getIndexById : function(id){
261         for(var i = 0, len = this.config.length; i < len; i++){
262             if(this.config[i].id == id){
263                 return i;
264             }
265         }
266         return -1;
267     },
268
269     <div id="method-Ext.grid.ColumnModel-moveColumn"></div>/**
270      * Moves a column from one position to another.
271      * @param {Number} oldIndex The index of the column to move.
272      * @param {Number} newIndex The position at which to reinsert the coolumn.
273      */
274     moveColumn : function(oldIndex, newIndex){
275         var c = this.config[oldIndex];
276         this.config.splice(oldIndex, 1);
277         this.config.splice(newIndex, 0, c);
278         this.dataMap = null;
279         this.fireEvent("columnmoved", this, oldIndex, newIndex);
280     },
281
282     <div id="method-Ext.grid.ColumnModel-getColumnCount"></div>/**
283      * Returns the number of columns.
284      * @param {Boolean} visibleOnly Optional. Pass as true to only include visible columns.
285      * @return {Number}
286      */
287     getColumnCount : function(visibleOnly){
288         if(visibleOnly === true){
289             var c = 0;
290             for(var i = 0, len = this.config.length; i < len; i++){
291                 if(!this.isHidden(i)){
292                     c++;
293                 }
294             }
295             return c;
296         }
297         return this.config.length;
298     },
299
300     <div id="method-Ext.grid.ColumnModel-getColumnsBy"></div>/**
301      * Returns the column configs that return true by the passed function that is called
302      * with (columnConfig, index)
303 <pre><code>
304 // returns an array of column config objects for all hidden columns
305 var columns = grid.getColumnModel().getColumnsBy(function(c){
306   return c.hidden;
307 });
308 </code></pre>
309      * @param {Function} fn A function which, when passed a {@link Ext.grid.Column Column} object, must
310      * return <code>true</code> if the column is to be included in the returned Array.
311      * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function
312      * is executed. Defaults to this ColumnModel.
313      * @return {Array} result
314      */
315     getColumnsBy : function(fn, scope){
316         var r = [];
317         for(var i = 0, len = this.config.length; i < len; i++){
318             var c = this.config[i];
319             if(fn.call(scope||this, c, i) === true){
320                 r[r.length] = c;
321             }
322         }
323         return r;
324     },
325
326     <div id="method-Ext.grid.ColumnModel-isSortable"></div>/**
327      * Returns true if the specified column is sortable.
328      * @param {Number} col The column index
329      * @return {Boolean}
330      */
331     isSortable : function(col){
332         return !!this.config[col].sortable;
333     },
334
335     <div id="method-Ext.grid.ColumnModel-isMenuDisabled"></div>/**
336      * Returns true if the specified column menu is disabled.
337      * @param {Number} col The column index
338      * @return {Boolean}
339      */
340     isMenuDisabled : function(col){
341         return !!this.config[col].menuDisabled;
342     },
343
344     <div id="method-Ext.grid.ColumnModel-getRenderer"></div>/**
345      * Returns the rendering (formatting) function defined for the column.
346      * @param {Number} col The column index.
347      * @return {Function} The function used to render the cell. See {@link #setRenderer}.
348      */
349     getRenderer : function(col){
350         if(!this.config[col].renderer){
351             return Ext.grid.ColumnModel.defaultRenderer;
352         }
353         return this.config[col].renderer;
354     },
355
356     getRendererScope : function(col){
357         return this.config[col].scope;
358     },
359
360     <div id="method-Ext.grid.ColumnModel-setRenderer"></div>/**
361      * Sets the rendering (formatting) function for a column.  See {@link Ext.util.Format} for some
362      * default formatting functions.
363      * @param {Number} col The column index
364      * @param {Function} fn The function to use to process the cell's raw data
365      * to return HTML markup for the grid view. The render function is called with
366      * the following parameters:<ul>
367      * <li><b>value</b> : Object<p class="sub-desc">The data value for the cell.</p></li>
368      * <li><b>metadata</b> : Object<p class="sub-desc">An object in which you may set the following attributes:<ul>
369      * <li><b>css</b> : String<p class="sub-desc">A CSS class name to add to the cell's TD element.</p></li>
370      * <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
371      * (e.g. 'style="color:red;"').</p></li></ul></p></li>
372      * <li><b>record</b> : Ext.data.record<p class="sub-desc">The {@link Ext.data.Record} from which the data was extracted.</p></li>
373      * <li><b>rowIndex</b> : Number<p class="sub-desc">Row index</p></li>
374      * <li><b>colIndex</b> : Number<p class="sub-desc">Column index</p></li>
375      * <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>
376      */
377     setRenderer : function(col, fn){
378         this.config[col].renderer = fn;
379     },
380
381     <div id="method-Ext.grid.ColumnModel-getColumnWidth"></div>/**
382      * Returns the width for the specified column.
383      * @param {Number} col The column index
384      * @return {Number}
385      */
386     getColumnWidth : function(col){
387         return this.config[col].width;
388     },
389
390     <div id="method-Ext.grid.ColumnModel-setColumnWidth"></div>/**
391      * Sets the width for a column.
392      * @param {Number} col The column index
393      * @param {Number} width The new width
394      * @param {Boolean} suppressEvent True to suppress firing the <code>{@link #widthchange}</code>
395      * event. Defaults to false.
396      */
397     setColumnWidth : function(col, width, suppressEvent){
398         this.config[col].width = width;
399         this.totalWidth = null;
400         if(!suppressEvent){
401              this.fireEvent("widthchange", this, col, width);
402         }
403     },
404
405     <div id="method-Ext.grid.ColumnModel-getTotalWidth"></div>/**
406      * Returns the total width of all columns.
407      * @param {Boolean} includeHidden True to include hidden column widths
408      * @return {Number}
409      */
410     getTotalWidth : function(includeHidden){
411         if(!this.totalWidth){
412             this.totalWidth = 0;
413             for(var i = 0, len = this.config.length; i < len; i++){
414                 if(includeHidden || !this.isHidden(i)){
415                     this.totalWidth += this.getColumnWidth(i);
416                 }
417             }
418         }
419         return this.totalWidth;
420     },
421
422     <div id="method-Ext.grid.ColumnModel-getColumnHeader"></div>/**
423      * Returns the header for the specified column.
424      * @param {Number} col The column index
425      * @return {String}
426      */
427     getColumnHeader : function(col){
428         return this.config[col].header;
429     },
430
431     <div id="method-Ext.grid.ColumnModel-setColumnHeader"></div>/**
432      * Sets the header for a column.
433      * @param {Number} col The column index
434      * @param {String} header The new header
435      */
436     setColumnHeader : function(col, header){
437         this.config[col].header = header;
438         this.fireEvent("headerchange", this, col, header);
439     },
440
441     <div id="method-Ext.grid.ColumnModel-getColumnTooltip"></div>/**
442      * Returns the tooltip for the specified column.
443      * @param {Number} col The column index
444      * @return {String}
445      */
446     getColumnTooltip : function(col){
447             return this.config[col].tooltip;
448     },
449     <div id="method-Ext.grid.ColumnModel-setColumnTooltip"></div>/**
450      * Sets the tooltip for a column.
451      * @param {Number} col The column index
452      * @param {String} tooltip The new tooltip
453      */
454     setColumnTooltip : function(col, tooltip){
455             this.config[col].tooltip = tooltip;
456     },
457
458     <div id="method-Ext.grid.ColumnModel-getDataIndex"></div>/**
459      * Returns the dataIndex for the specified column.
460 <pre><code>
461 // Get field name for the column
462 var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
463 </code></pre>
464      * @param {Number} col The column index
465      * @return {String} The column's dataIndex
466      */
467     getDataIndex : function(col){
468         return this.config[col].dataIndex;
469     },
470
471     <div id="method-Ext.grid.ColumnModel-setDataIndex"></div>/**
472      * Sets the dataIndex for a column.
473      * @param {Number} col The column index
474      * @param {String} dataIndex The new dataIndex
475      */
476     setDataIndex : function(col, dataIndex){
477         this.config[col].dataIndex = dataIndex;
478     },
479
480     <div id="method-Ext.grid.ColumnModel-findColumnIndex"></div>/**
481      * Finds the index of the first matching column for the given dataIndex.
482      * @param {String} col The dataIndex to find
483      * @return {Number} The column index, or -1 if no match was found
484      */
485     findColumnIndex : function(dataIndex){
486         var c = this.config;
487         for(var i = 0, len = c.length; i < len; i++){
488             if(c[i].dataIndex == dataIndex){
489                 return i;
490             }
491         }
492         return -1;
493     },
494
495     <div id="method-Ext.grid.ColumnModel-isCellEditable"></div>/**
496      * Returns true if the cell is editable.
497 <pre><code>
498 var store = new Ext.data.Store({...});
499 var colModel = new Ext.grid.ColumnModel({
500   columns: [...],
501   isCellEditable: function(col, row) {
502     var record = store.getAt(row);
503     if (record.get('readonly')) { // replace with your condition
504       return false;
505     }
506     return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
507   }
508 });
509 var grid = new Ext.grid.GridPanel({
510   store: store,
511   colModel: colModel,
512   ...
513 });
514 </code></pre>
515      * @param {Number} colIndex The column index
516      * @param {Number} rowIndex The row index
517      * @return {Boolean}
518      */
519     isCellEditable : function(colIndex, rowIndex){
520         var c = this.config[colIndex],
521             ed = c.editable;
522
523         //force boolean
524         return !!(ed || (!Ext.isDefined(ed) && c.editor));
525     },
526
527     <div id="method-Ext.grid.ColumnModel-getCellEditor"></div>/**
528      * Returns the editor defined for the cell/column.
529      * @param {Number} colIndex The column index
530      * @param {Number} rowIndex The row index
531      * @return {Ext.Editor} The {@link Ext.Editor Editor} that was created to wrap
532      * the {@link Ext.form.Field Field} used to edit the cell.
533      */
534     getCellEditor : function(colIndex, rowIndex){
535         return this.config[colIndex].getCellEditor(rowIndex);
536     },
537
538     <div id="method-Ext.grid.ColumnModel-setEditable"></div>/**
539      * Sets if a column is editable.
540      * @param {Number} col The column index
541      * @param {Boolean} editable True if the column is editable
542      */
543     setEditable : function(col, editable){
544         this.config[col].editable = editable;
545     },
546
547     <div id="method-Ext.grid.ColumnModel-isHidden"></div>/**
548      * Returns <tt>true</tt> if the column is <code>{@link Ext.grid.Column#hidden hidden}</code>,
549      * <tt>false</tt> otherwise.
550      * @param {Number} colIndex The column index
551      * @return {Boolean}
552      */
553     isHidden : function(colIndex){
554         return !!this.config[colIndex].hidden; // ensure returns boolean
555     },
556
557     <div id="method-Ext.grid.ColumnModel-isFixed"></div>/**
558      * Returns <tt>true</tt> if the column is <code>{@link Ext.grid.Column#fixed fixed}</code>,
559      * <tt>false</tt> otherwise.
560      * @param {Number} colIndex The column index
561      * @return {Boolean}
562      */
563     isFixed : function(colIndex){
564         return !!this.config[colIndex].fixed;
565     },
566
567     <div id="method-Ext.grid.ColumnModel-isResizable"></div>/**
568      * Returns true if the column can be resized
569      * @return {Boolean}
570      */
571     isResizable : function(colIndex){
572         return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
573     },
574     <div id="method-Ext.grid.ColumnModel-setHidden"></div>/**
575      * Sets if a column is hidden.
576 <pre><code>
577 myGrid.getColumnModel().setHidden(0, true); // hide column 0 (0 = the first column).
578 </code></pre>
579      * @param {Number} colIndex The column index
580      * @param {Boolean} hidden True if the column is hidden
581      */
582     setHidden : function(colIndex, hidden){
583         var c = this.config[colIndex];
584         if(c.hidden !== hidden){
585             c.hidden = hidden;
586             this.totalWidth = null;
587             this.fireEvent("hiddenchange", this, colIndex, hidden);
588         }
589     },
590
591     <div id="method-Ext.grid.ColumnModel-setEditor"></div>/**
592      * Sets the editor for a column and destroys the prior editor.
593      * @param {Number} col The column index
594      * @param {Object} editor The editor object
595      */
596     setEditor : function(col, editor){
597         this.config[col].setEditor(editor);
598     },
599
600     <div id="method-Ext.grid.ColumnModel-destroy"></div>/**
601      * Destroys this column model by purging any event listeners, and removing any editors.
602      */
603     destroy : function(){
604         var c;
605         for(var i = 0, len = this.config.length; i < len; i++){
606             c = this.config[i];
607             if(c.setEditor){
608                 c.setEditor(null);
609             }
610         }
611         this.purgeListeners();
612     },
613     
614     /**
615      * @private
616      * Setup any saved state for the column, ensures that defaults are applied.
617      */
618     setState : function(col, state){
619         Ext.applyIf(this.config[col], state);
620     }
621 });
622
623 // private
624 Ext.grid.ColumnModel.defaultRenderer = function(value){
625     if(typeof value == "string" && value.length < 1){
626         return "&#160;";
627     }
628     return value;
629 };</pre>    
630 </body>
631 </html>