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