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>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.grid.GridPanel"></div>/**
16 * @class Ext.grid.GridPanel
18 * <p>This class represents the primary interface of a component based grid control to represent data
19 * in a tabular format of rows and columns. The GridPanel is composed of the following:</p>
20 * <div class="mdetail-params"><ul>
21 * <li><b>{@link Ext.data.Store Store}</b> : The Model holding the data records (rows)
22 * <div class="sub-desc"></div></li>
23 * <li><b>{@link Ext.grid.ColumnModel Column model}</b> : Column makeup
24 * <div class="sub-desc"></div></li>
25 * <li><b>{@link Ext.grid.GridView View}</b> : Encapsulates the user interface
26 * <div class="sub-desc"></div></li>
27 * <li><b>{@link Ext.grid.AbstractSelectionModel selection model}</b> : Selection behavior
28 * <div class="sub-desc"></div></li>
30 * <p>Example usage:</p>
32 var grid = new Ext.grid.GridPanel({
33 {@link #store}: new {@link Ext.data.Store}({
34 {@link Ext.data.Store#autoDestroy autoDestroy}: true,
35 {@link Ext.data.Store#reader reader}: reader,
36 {@link Ext.data.Store#data data}: xg.dummyData
38 {@link #colModel}: new {@link Ext.grid.ColumnModel}({
39 {@link Ext.grid.ColumnModel#defaults defaults}: {
43 {@link Ext.grid.ColumnModel#columns columns}: [
44 {id: 'company', header: 'Company', width: 200, sortable: true, dataIndex: 'company'},
45 {header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
46 {header: 'Change', dataIndex: 'change'},
47 {header: '% Change', dataIndex: 'pctChange'},
48 // instead of specifying renderer: Ext.util.Format.dateRenderer('m/d/Y') use xtype
50 header: 'Last Updated', width: 135, dataIndex: 'lastChange',
51 xtype: 'datecolumn', format: 'M d, Y'
55 {@link #viewConfig}: {
56 {@link Ext.grid.GridView#forceFit forceFit}: true,
58 // Return CSS class to apply to rows depending upon data values
59 {@link Ext.grid.GridView#getRowClass getRowClass}: function(record, index) {
60 var c = record.{@link Ext.data.Record#get get}('change');
68 {@link #sm}: new Ext.grid.RowSelectionModel({singleSelect:true}),
72 title: 'Framed with Row Selection and Horizontal Scrolling',
76 * <p><b><u>Notes:</u></b></p>
77 * <div class="mdetail-params"><ul>
78 * <li>Although this class inherits many configuration options from base classes, some of them
79 * (such as autoScroll, autoWidth, layout, items, etc) are not used by this class, and will
80 * have no effect.</li>
81 * <li>A grid <b>requires</b> a width in which to scroll its columns, and a height in which to
82 * scroll its rows. These dimensions can either be set explicitly through the
83 * <tt>{@link Ext.BoxComponent#height height}</tt> and <tt>{@link Ext.BoxComponent#width width}</tt>
84 * configuration options or implicitly set by using the grid as a child item of a
85 * {@link Ext.Container Container} which will have a {@link Ext.Container#layout layout manager}
86 * provide the sizing of its child items (for example the Container of the Grid may specify
87 * <tt>{@link Ext.Container#layout layout}:'fit'</tt>).</li>
88 * <li>To access the data in a Grid, it is necessary to use the data model encapsulated
89 * by the {@link #store Store}. See the {@link #cellclick} event for more details.</li>
92 * @param {Object} config The config object
95 Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
96 <div id="cfg-Ext.grid.GridPanel-autoExpandColumn"></div>/**
97 * @cfg {String} autoExpandColumn
98 * <p>The <tt>{@link Ext.grid.Column#id id}</tt> of a {@link Ext.grid.Column column} in
99 * this grid that should expand to fill unused space. This value specified here can not
101 * <br><p><b>Note</b>: If the Grid's {@link Ext.grid.GridView view} is configured with
102 * <tt>{@link Ext.grid.GridView#forceFit forceFit}=true</tt> the <tt>autoExpandColumn</tt>
103 * is ignored. See {@link Ext.grid.Column}.<tt>{@link Ext.grid.Column#width width}</tt>
104 * for additional details.</p>
105 * <p>See <tt>{@link #autoExpandMax}</tt> and <tt>{@link #autoExpandMin}</tt> also.</p>
107 autoExpandColumn : false,
108 <div id="cfg-Ext.grid.GridPanel-autoExpandMax"></div>/**
109 * @cfg {Number} autoExpandMax The maximum width the <tt>{@link #autoExpandColumn}</tt>
110 * can have (if enabled). Defaults to <tt>1000</tt>.
112 autoExpandMax : 1000,
113 <div id="cfg-Ext.grid.GridPanel-autoExpandMin"></div>/**
114 * @cfg {Number} autoExpandMin The minimum width the <tt>{@link #autoExpandColumn}</tt>
115 * can have (if enabled). Defaults to <tt>50</tt>.
118 <div id="cfg-Ext.grid.GridPanel-columnLines"></div>/**
119 * @cfg {Boolean} columnLines <tt>true</tt> to add css for column separation lines.
120 * Default is <tt>false</tt>.
123 <div id="cfg-Ext.grid.GridPanel-cm"></div>/**
124 * @cfg {Object} cm Shorthand for <tt>{@link #colModel}</tt>.
126 <div id="cfg-Ext.grid.GridPanel-colModel"></div>/**
127 * @cfg {Object} colModel The {@link Ext.grid.ColumnModel} to use when rendering the grid (required).
129 <div id="cfg-Ext.grid.GridPanel-columns"></div>/**
130 * @cfg {Array} columns An array of {@link Ext.grid.Column columns} to auto create a
131 * {@link Ext.grid.ColumnModel}. The ColumnModel may be explicitly created via the
132 * <tt>{@link #colModel}</tt> configuration property.
134 <div id="cfg-Ext.grid.GridPanel-ddGroup"></div>/**
135 * @cfg {String} ddGroup The DD group this GridPanel belongs to. Defaults to <tt>'GridDD'</tt> if not specified.
137 <div id="cfg-Ext.grid.GridPanel-ddText"></div>/**
138 * @cfg {String} ddText
139 * Configures the text in the drag proxy. Defaults to:
141 * ddText : '{0} selected row{1}'
143 * <tt>{0}</tt> is replaced with the number of selected rows.
145 ddText : '{0} selected row{1}',
146 <div id="cfg-Ext.grid.GridPanel-deferRowRender"></div>/**
147 * @cfg {Boolean} deferRowRender <P>Defaults to <tt>true</tt> to enable deferred row rendering.</p>
148 * <p>This allows the GridPanel to be initially rendered empty, with the expensive update of the row
149 * structure deferred so that layouts with GridPanels appear more quickly.</p>
151 deferRowRender : true,
152 <div id="cfg-Ext.grid.GridPanel-disableSelection"></div>/**
153 * @cfg {Boolean} disableSelection <p><tt>true</tt> to disable selections in the grid. Defaults to <tt>false</tt>.</p>
154 * <p>Ignored if a {@link #selModel SelectionModel} is specified.</p>
156 <div id="cfg-Ext.grid.GridPanel-enableColumnResize"></div>/**
157 * @cfg {Boolean} enableColumnResize <tt>false</tt> to turn off column resizing for the whole grid. Defaults to <tt>true</tt>.
159 <div id="cfg-Ext.grid.GridPanel-enableColumnHide"></div>/**
160 * @cfg {Boolean} enableColumnHide
161 * Defaults to <tt>true</tt> to enable {@link Ext.grid.Column#hidden hiding of columns}
162 * with the {@link #enableHdMenu header menu}.
164 enableColumnHide : true,
165 <div id="cfg-Ext.grid.GridPanel-enableColumnMove"></div>/**
166 * @cfg {Boolean} enableColumnMove Defaults to <tt>true</tt> to enable drag and drop reorder of columns. <tt>false</tt>
167 * to turn off column reordering via drag drop.
169 enableColumnMove : true,
170 <div id="cfg-Ext.grid.GridPanel-enableDragDrop"></div>/**
171 * @cfg {Boolean} enableDragDrop <p>Enables dragging of the selected rows of the GridPanel. Defaults to <tt>false</tt>.</p>
172 * <p>Setting this to <b><tt>true</tt></b> causes this GridPanel's {@link #getView GridView} to
173 * create an instance of {@link Ext.grid.GridDragZone}. <b>Note</b>: this is available only <b>after</b>
174 * the Grid has been rendered as the GridView's <tt>{@link Ext.grid.GridView#dragZone dragZone}</tt>
176 * <p>A cooperating {@link Ext.dd.DropZone DropZone} must be created who's implementations of
177 * {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
178 * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} are able
179 * to process the {@link Ext.grid.GridDragZone#getDragData data} which is provided.</p>
181 enableDragDrop : false,
182 <div id="cfg-Ext.grid.GridPanel-enableHdMenu"></div>/**
183 * @cfg {Boolean} enableHdMenu Defaults to <tt>true</tt> to enable the drop down button for menu in the headers.
186 <div id="cfg-Ext.grid.GridPanel-hideHeaders"></div>/**
187 * @cfg {Boolean} hideHeaders True to hide the grid's header. Defaults to <code>false</code>.
189 <div id="cfg-Ext.grid.GridPanel-loadMask"></div>/**
190 * @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the grid while
191 * loading. Defaults to <code>false</code>.
194 <div id="cfg-Ext.grid.GridPanel-maxHeight"></div>/**
195 * @cfg {Number} maxHeight Sets the maximum height of the grid - ignored if <tt>autoHeight</tt> is not on.
197 <div id="cfg-Ext.grid.GridPanel-minColumnWidth"></div>/**
198 * @cfg {Number} minColumnWidth The minimum width a column can be resized to. Defaults to <tt>25</tt>.
201 <div id="cfg-Ext.grid.GridPanel-sm"></div>/**
202 * @cfg {Object} sm Shorthand for <tt>{@link #selModel}</tt>.
204 <div id="cfg-Ext.grid.GridPanel-selModel"></div>/**
205 * @cfg {Object} selModel Any subclass of {@link Ext.grid.AbstractSelectionModel} that will provide
206 * the selection model for the grid (defaults to {@link Ext.grid.RowSelectionModel} if not specified).
208 <div id="cfg-Ext.grid.GridPanel-store"></div>/**
209 * @cfg {Ext.data.Store} store The {@link Ext.data.Store} the grid should use as its data source (required).
211 <div id="cfg-Ext.grid.GridPanel-stripeRows"></div>/**
212 * @cfg {Boolean} stripeRows <tt>true</tt> to stripe the rows. Default is <tt>false</tt>.
213 * <p>This causes the CSS class <tt><b>x-grid3-row-alt</b></tt> to be added to alternate rows of
214 * the grid. A default CSS rule is provided which sets a background colour, but you can override this
215 * with a rule which either overrides the <b>background-color</b> style using the '!important'
216 * modifier, or which uses a CSS selector of higher specificity.</p>
219 <div id="cfg-Ext.grid.GridPanel-trackMouseOver"></div>/**
220 * @cfg {Boolean} trackMouseOver True to highlight rows when the mouse is over. Default is <tt>true</tt>
221 * for GridPanel, but <tt>false</tt> for EditorGridPanel.
223 trackMouseOver : true,
224 <div id="cfg-Ext.grid.GridPanel-stateEvents"></div>/**
225 * @cfg {Array} stateEvents
226 * An array of events that, when fired, should trigger this component to save its state.
227 * Defaults to:<pre><code>
228 * stateEvents: ['columnmove', 'columnresize', 'sortchange', 'groupchange']
230 * <p>These can be any types of events supported by this component, including browser or
231 * custom events (e.g., <tt>['click', 'customerchange']</tt>).</p>
232 * <p>See {@link Ext.Component#stateful} for an explanation of saving and restoring
233 * Component state.</p>
235 stateEvents : ['columnmove', 'columnresize', 'sortchange', 'groupchange'],
236 <div id="cfg-Ext.grid.GridPanel-view"></div>/**
237 * @cfg {Object} view The {@link Ext.grid.GridView} used by the grid. This can be set
238 * before a call to {@link Ext.Component#render render()}.
242 <div id="cfg-Ext.grid.GridPanel-bubbleEvents"></div>/**
243 * @cfg {Array} bubbleEvents
244 * <p>An array of events that, when fired, should be bubbled to any parent container.
245 * See {@link Ext.util.Observable#enableBubble}.
246 * Defaults to <tt>[]</tt>.
250 <div id="cfg-Ext.grid.GridPanel-viewConfig"></div>/**
251 * @cfg {Object} viewConfig A config object that will be applied to the grid's UI view. Any of
252 * the config options available for {@link Ext.grid.GridView} can be specified here. This option
253 * is ignored if <tt>{@link #view}</tt> is specified.
262 initComponent : function(){
263 Ext.grid.GridPanel.superclass.initComponent.call(this);
265 if(this.columnLines){
266 this.cls = (this.cls || '') + ' x-grid-with-col-lines';
268 // override any provided value since it isn't valid
269 // and is causing too many bug reports ;)
270 this.autoScroll = false;
271 this.autoWidth = false;
273 if(Ext.isArray(this.columns)){
274 this.colModel = new Ext.grid.ColumnModel(this.columns);
278 // check and correct shorthanded configs
280 this.store = this.ds;
284 this.colModel = this.cm;
288 this.selModel = this.sm;
291 this.store = Ext.StoreMgr.lookup(this.store);
295 <div id="event-Ext.grid.GridPanel-click"></div>/**
297 * The raw click event for the entire grid.
298 * @param {Ext.EventObject} e
301 <div id="event-Ext.grid.GridPanel-dblclick"></div>/**
303 * The raw dblclick event for the entire grid.
304 * @param {Ext.EventObject} e
307 <div id="event-Ext.grid.GridPanel-contextmenu"></div>/**
309 * The raw contextmenu event for the entire grid.
310 * @param {Ext.EventObject} e
313 <div id="event-Ext.grid.GridPanel-mousedown"></div>/**
315 * The raw mousedown event for the entire grid.
316 * @param {Ext.EventObject} e
319 <div id="event-Ext.grid.GridPanel-mouseup"></div>/**
321 * The raw mouseup event for the entire grid.
322 * @param {Ext.EventObject} e
325 <div id="event-Ext.grid.GridPanel-mouseover"></div>/**
327 * The raw mouseover event for the entire grid.
328 * @param {Ext.EventObject} e
331 <div id="event-Ext.grid.GridPanel-mouseout"></div>/**
333 * The raw mouseout event for the entire grid.
334 * @param {Ext.EventObject} e
337 <div id="event-Ext.grid.GridPanel-keypress"></div>/**
339 * The raw keypress event for the entire grid.
340 * @param {Ext.EventObject} e
343 <div id="event-Ext.grid.GridPanel-keydown"></div>/**
345 * The raw keydown event for the entire grid.
346 * @param {Ext.EventObject} e
351 <div id="event-Ext.grid.GridPanel-cellmousedown"></div>/**
352 * @event cellmousedown
353 * Fires before a cell is clicked
355 * @param {Number} rowIndex
356 * @param {Number} columnIndex
357 * @param {Ext.EventObject} e
360 <div id="event-Ext.grid.GridPanel-rowmousedown"></div>/**
361 * @event rowmousedown
362 * Fires before a row is clicked
364 * @param {Number} rowIndex
365 * @param {Ext.EventObject} e
368 <div id="event-Ext.grid.GridPanel-headermousedown"></div>/**
369 * @event headermousedown
370 * Fires before a header is clicked
372 * @param {Number} columnIndex
373 * @param {Ext.EventObject} e
377 <div id="event-Ext.grid.GridPanel-groupmousedown"></div>/**
378 * @event groupmousedown
379 * Fires before a group header is clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
381 * @param {String} groupField
382 * @param {String} groupValue
383 * @param {Ext.EventObject} e
387 <div id="event-Ext.grid.GridPanel-rowbodymousedown"></div>/**
388 * @event rowbodymousedown
389 * Fires before the row body is clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
391 * @param {Number} rowIndex
392 * @param {Ext.EventObject} e
396 <div id="event-Ext.grid.GridPanel-containermousedown"></div>/**
397 * @event containermousedown
398 * Fires before the container is clicked. The container consists of any part of the grid body that is not covered by a row.
400 * @param {Ext.EventObject} e
402 'containermousedown',
404 <div id="event-Ext.grid.GridPanel-cellclick"></div>/**
406 * Fires when a cell is clicked.
407 * The data for the cell is drawn from the {@link Ext.data.Record Record}
408 * for this row. To access the data in the listener function use the
409 * following technique:
411 function(grid, rowIndex, columnIndex, e) {
412 var record = grid.getStore().getAt(rowIndex); // Get the Record
413 var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
414 var data = record.get(fieldName);
418 * @param {Number} rowIndex
419 * @param {Number} columnIndex
420 * @param {Ext.EventObject} e
423 <div id="event-Ext.grid.GridPanel-celldblclick"></div>/**
424 * @event celldblclick
425 * Fires when a cell is double clicked
427 * @param {Number} rowIndex
428 * @param {Number} columnIndex
429 * @param {Ext.EventObject} e
432 <div id="event-Ext.grid.GridPanel-rowclick"></div>/**
434 * Fires when a row is clicked
436 * @param {Number} rowIndex
437 * @param {Ext.EventObject} e
440 <div id="event-Ext.grid.GridPanel-rowdblclick"></div>/**
442 * Fires when a row is double clicked
444 * @param {Number} rowIndex
445 * @param {Ext.EventObject} e
448 <div id="event-Ext.grid.GridPanel-headerclick"></div>/**
450 * Fires when a header is clicked
452 * @param {Number} columnIndex
453 * @param {Ext.EventObject} e
456 <div id="event-Ext.grid.GridPanel-headerdblclick"></div>/**
457 * @event headerdblclick
458 * Fires when a header cell is double clicked
460 * @param {Number} columnIndex
461 * @param {Ext.EventObject} e
464 <div id="event-Ext.grid.GridPanel-groupclick"></div>/**
466 * Fires when group header is clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
468 * @param {String} groupField
469 * @param {String} groupValue
470 * @param {Ext.EventObject} e
473 <div id="event-Ext.grid.GridPanel-groupdblclick"></div>/**
474 * @event groupdblclick
475 * Fires when group header is double clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
477 * @param {String} groupField
478 * @param {String} groupValue
479 * @param {Ext.EventObject} e
482 <div id="event-Ext.grid.GridPanel-containerclick"></div>/**
483 * @event containerclick
484 * Fires when the container is clicked. The container consists of any part of the grid body that is not covered by a row.
486 * @param {Ext.EventObject} e
489 <div id="event-Ext.grid.GridPanel-containerdblclick"></div>/**
490 * @event containerdblclick
491 * Fires when the container is double clicked. The container consists of any part of the grid body that is not covered by a row.
493 * @param {Ext.EventObject} e
497 <div id="event-Ext.grid.GridPanel-rowbodyclick"></div>/**
498 * @event rowbodyclick
499 * Fires when the row body is clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
501 * @param {Number} rowIndex
502 * @param {Ext.EventObject} e
505 <div id="event-Ext.grid.GridPanel-rowbodydblclick"></div>/**
506 * @event rowbodydblclick
507 * Fires when the row body is double clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
509 * @param {Number} rowIndex
510 * @param {Ext.EventObject} e
514 <div id="event-Ext.grid.GridPanel-rowcontextmenu"></div>/**
515 * @event rowcontextmenu
516 * Fires when a row is right clicked
518 * @param {Number} rowIndex
519 * @param {Ext.EventObject} e
522 <div id="event-Ext.grid.GridPanel-cellcontextmenu"></div>/**
523 * @event cellcontextmenu
524 * Fires when a cell is right clicked
526 * @param {Number} rowIndex
527 * @param {Number} cellIndex
528 * @param {Ext.EventObject} e
531 <div id="event-Ext.grid.GridPanel-headercontextmenu"></div>/**
532 * @event headercontextmenu
533 * Fires when a header is right clicked
535 * @param {Number} columnIndex
536 * @param {Ext.EventObject} e
539 <div id="event-Ext.grid.GridPanel-groupcontextmenu"></div>/**
540 * @event groupcontextmenu
541 * Fires when group header is right clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
543 * @param {String} groupField
544 * @param {String} groupValue
545 * @param {Ext.EventObject} e
548 <div id="event-Ext.grid.GridPanel-containercontextmenu"></div>/**
549 * @event containercontextmenu
550 * Fires when the container is right clicked. The container consists of any part of the grid body that is not covered by a row.
552 * @param {Ext.EventObject} e
554 'containercontextmenu',
555 <div id="event-Ext.grid.GridPanel-rowbodycontextmenu"></div>/**
556 * @event rowbodycontextmenu
557 * Fires when the row body is right clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
559 * @param {Number} rowIndex
560 * @param {Ext.EventObject} e
562 'rowbodycontextmenu',
563 <div id="event-Ext.grid.GridPanel-bodyscroll"></div>/**
565 * Fires when the body element is scrolled
566 * @param {Number} scrollLeft
567 * @param {Number} scrollTop
570 <div id="event-Ext.grid.GridPanel-columnresize"></div>/**
571 * @event columnresize
572 * Fires when the user resizes a column
573 * @param {Number} columnIndex
574 * @param {Number} newSize
577 <div id="event-Ext.grid.GridPanel-columnmove"></div>/**
579 * Fires when the user moves a column
580 * @param {Number} oldIndex
581 * @param {Number} newIndex
584 <div id="event-Ext.grid.GridPanel-sortchange"></div>/**
586 * Fires when the grid's store sort changes
588 * @param {Object} sortInfo An object with the keys field and direction
591 <div id="event-Ext.grid.GridPanel-groupchange"></div>/**
593 * Fires when the grid's grouping changes (only applies for grids with a {@link Ext.grid.GroupingView GroupingView})
595 * @param {String} groupField A string with the grouping field, null if the store is not grouped.
598 <div id="event-Ext.grid.GridPanel-reconfigure"></div>/**
600 * Fires when the grid is reconfigured with a new store and/or column model.
602 * @param {Ext.data.Store} store The new store
603 * @param {Ext.grid.ColumnModel} colModel The new column model
606 <div id="event-Ext.grid.GridPanel-viewready"></div>/**
608 * Fires when the grid view is available (use this for selecting a default row).
616 onRender : function(ct, position){
617 Ext.grid.GridPanel.superclass.onRender.apply(this, arguments);
619 var c = this.getGridEl();
621 this.el.addClass('x-grid-panel');
625 mousedown: this.onMouseDown,
627 dblclick: this.onDblClick,
628 contextmenu: this.onContextMenu
631 this.relayEvents(c, ['mousedown','mouseup','mouseover','mouseout','keypress', 'keydown']);
633 var view = this.getView();
636 this.getSelectionModel().init(this);
640 initEvents : function(){
641 Ext.grid.GridPanel.superclass.initEvents.call(this);
644 this.loadMask = new Ext.LoadMask(this.bwrap,
645 Ext.apply({store:this.store}, this.loadMask));
649 initStateEvents : function(){
650 Ext.grid.GridPanel.superclass.initStateEvents.call(this);
651 this.mon(this.colModel, 'hiddenchange', this.saveState, this, {delay: 100});
654 applyState : function(state){
655 var cm = this.colModel,
663 for(var i = 0, len = cs.length; i < len; i++){
665 c = cm.getColumnById(s.id);
669 oldIndex = cm.getIndexById(s.id);
671 cm.moveColumn(oldIndex, i);
679 store[store.remoteSort ? 'setDefaultSort' : 'sort'](s.field, s.direction);
686 store.clearGrouping();
691 var o = Ext.apply({}, state);
694 Ext.grid.GridPanel.superclass.applyState.call(this, o);
697 getState : function(){
698 var o = {columns: []},
703 for(var i = 0, c; (c = this.colModel.config[i]); i++){
709 o.columns[i].hidden = true;
713 ss = store.getSortState();
717 if(store.getGroupState){
718 gs = store.getGroupState();
728 afterRender : function(){
729 Ext.grid.GridPanel.superclass.afterRender.call(this);
731 this.on('bodyresize', v.layout, v);
733 if(this.deferRowRender){
734 if (!this.deferRowRenderTask){
735 this.deferRowRenderTask = new Ext.util.DelayedTask(v.afterRender, this.view);
737 this.deferRowRenderTask.delay(10);
741 this.viewReady = true;
744 <div id="method-Ext.grid.GridPanel-reconfigure"></div>/**
745 * <p>Reconfigures the grid to use a different Store and Column Model
746 * and fires the 'reconfigure' event. The View will be bound to the new
747 * objects and refreshed.</p>
748 * <p>Be aware that upon reconfiguring a GridPanel, certain existing settings <i>may</i> become
749 * invalidated. For example the configured {@link #autoExpandColumn} may no longer exist in the
750 * new ColumnModel. Also, an existing {@link Ext.PagingToolbar PagingToolbar} will still be bound
751 * to the old Store, and will need rebinding. Any {@link #plugins} might also need reconfiguring
752 * with the new data.</p>
753 * @param {Ext.data.Store} store The new {@link Ext.data.Store} object
754 * @param {Ext.grid.ColumnModel} colModel The new {@link Ext.grid.ColumnModel} object
756 reconfigure : function(store, colModel){
757 var rendered = this.rendered;
760 this.loadMask.destroy();
761 this.loadMask = new Ext.LoadMask(this.bwrap,
762 Ext.apply({}, {store:store}, this.initialConfig.loadMask));
766 this.view.initData(store, colModel);
769 this.colModel = colModel;
771 this.view.refresh(true);
773 this.fireEvent('reconfigure', this, store, colModel);
777 onDestroy : function(){
778 if (this.deferRowRenderTask && this.deferRowRenderTask.cancel){
779 this.deferRowRenderTask.cancel();
782 Ext.destroy(this.view, this.loadMask);
783 }else if(this.store && this.store.autoDestroy){
784 this.store.destroy();
786 Ext.destroy(this.colModel, this.selModel);
787 this.store = this.selModel = this.colModel = this.view = this.loadMask = null;
788 Ext.grid.GridPanel.superclass.onDestroy.call(this);
792 processEvent : function(name, e){
793 this.view.processEvent(name, e);
797 onClick : function(e){
798 this.processEvent('click', e);
802 onMouseDown : function(e){
803 this.processEvent('mousedown', e);
807 onContextMenu : function(e, t){
808 this.processEvent('contextmenu', e);
812 onDblClick : function(e){
813 this.processEvent('dblclick', e);
817 walkCells : function(row, col, step, fn, scope){
818 var cm = this.colModel,
819 clen = cm.getColumnCount(),
821 rlen = ds.getCount(),
835 if(fn.call(scope || this, row, col, cm) === true){
853 if(fn.call(scope || this, row, col, cm) === true){
864 <div id="method-Ext.grid.GridPanel-getGridEl"></div>/**
865 * Returns the grid's underlying element.
866 * @return {Element} The element
868 getGridEl : function(){
872 // private for compatibility, overridden by editor grid
873 stopEditing : Ext.emptyFn,
875 <div id="method-Ext.grid.GridPanel-getSelectionModel"></div>/**
876 * Returns the grid's selection model configured by the <code>{@link #selModel}</code>
877 * configuration option. If no selection model was configured, this will create
878 * and return a {@link Ext.grid.RowSelectionModel RowSelectionModel}.
879 * @return {SelectionModel}
881 getSelectionModel : function(){
883 this.selModel = new Ext.grid.RowSelectionModel(
884 this.disableSelection ? {selectRow: Ext.emptyFn} : null);
886 return this.selModel;
889 <div id="method-Ext.grid.GridPanel-getStore"></div>/**
890 * Returns the grid's data store.
891 * @return {Ext.data.Store} The store
893 getStore : function(){
897 <div id="method-Ext.grid.GridPanel-getColumnModel"></div>/**
898 * Returns the grid's ColumnModel.
899 * @return {Ext.grid.ColumnModel} The column model
901 getColumnModel : function(){
902 return this.colModel;
905 <div id="method-Ext.grid.GridPanel-getView"></div>/**
906 * Returns the grid's GridView object.
907 * @return {Ext.grid.GridView} The grid view
909 getView : function(){
911 this.view = new Ext.grid.GridView(this.viewConfig);
915 <div id="method-Ext.grid.GridPanel-getDragDropText"></div>/**
916 * Called to get grid's drag proxy text, by default returns this.ddText.
917 * @return {String} The text
919 getDragDropText : function(){
920 var count = this.selModel.getCount();
921 return String.format(this.ddText, count, count == 1 ? '' : 's');
924 <div id="cfg-Ext.grid.GridPanel-activeItem"></div>/**
925 * @cfg {String/Number} activeItem
928 <div id="cfg-Ext.grid.GridPanel-autoDestroy"></div>/**
929 * @cfg {Boolean} autoDestroy
932 <div id="cfg-Ext.grid.GridPanel-autoLoad"></div>/**
933 * @cfg {Object/String/Function} autoLoad
936 <div id="cfg-Ext.grid.GridPanel-autoWidth"></div>/**
937 * @cfg {Boolean} autoWidth
940 <div id="cfg-Ext.grid.GridPanel-bufferResize"></div>/**
941 * @cfg {Boolean/Number} bufferResize
944 <div id="cfg-Ext.grid.GridPanel-defaultType"></div>/**
945 * @cfg {String} defaultType
948 <div id="cfg-Ext.grid.GridPanel-defaults"></div>/**
949 * @cfg {Object} defaults
952 <div id="cfg-Ext.grid.GridPanel-hideBorders"></div>/**
953 * @cfg {Boolean} hideBorders
956 <div id="cfg-Ext.grid.GridPanel-items"></div>/**
960 <div id="cfg-Ext.grid.GridPanel-layout"></div>/**
961 * @cfg {String} layout
964 <div id="cfg-Ext.grid.GridPanel-layoutConfig"></div>/**
965 * @cfg {Object} layoutConfig
968 <div id="cfg-Ext.grid.GridPanel-monitorResize"></div>/**
969 * @cfg {Boolean} monitorResize
972 <div id="prop-Ext.grid.GridPanel-items"></div>/**
976 <div id="method-Ext.grid.GridPanel-add"></div>/**
980 <div id="method-Ext.grid.GridPanel-cascade"></div>/**
984 <div id="method-Ext.grid.GridPanel-doLayout"></div>/**
988 <div id="method-Ext.grid.GridPanel-find"></div>/**
992 <div id="method-Ext.grid.GridPanel-findBy"></div>/**
996 <div id="method-Ext.grid.GridPanel-findById"></div>/**
1000 <div id="method-Ext.grid.GridPanel-findByType"></div>/**
1001 * @method findByType
1004 <div id="method-Ext.grid.GridPanel-getComponent"></div>/**
1005 * @method getComponent
1008 <div id="method-Ext.grid.GridPanel-getLayout"></div>/**
1012 <div id="method-Ext.grid.GridPanel-getUpdater"></div>/**
1013 * @method getUpdater
1016 <div id="method-Ext.grid.GridPanel-insert"></div>/**
1020 <div id="method-Ext.grid.GridPanel-load"></div>/**
1024 <div id="method-Ext.grid.GridPanel-remove"></div>/**
1028 <div id="event-Ext.grid.GridPanel-add"></div>/**
1032 <div id="event-Ext.grid.GridPanel-afterlayout"></div>/**
1033 * @event afterlayout
1036 <div id="event-Ext.grid.GridPanel-beforeadd"></div>/**
1040 <div id="event-Ext.grid.GridPanel-beforeremove"></div>/**
1041 * @event beforeremove
1044 <div id="event-Ext.grid.GridPanel-remove"></div>/**
1051 <div id="cfg-Ext.grid.GridPanel-allowDomMove"></div>/**
1052 * @cfg {String} allowDomMove @hide
1054 <div id="cfg-Ext.grid.GridPanel-autoEl"></div>/**
1055 * @cfg {String} autoEl @hide
1057 <div id="cfg-Ext.grid.GridPanel-applyTo"></div>/**
1058 * @cfg {String} applyTo @hide
1060 <div id="cfg-Ext.grid.GridPanel-autoScroll"></div>/**
1061 * @cfg {String} autoScroll @hide
1063 <div id="cfg-Ext.grid.GridPanel-bodyBorder"></div>/**
1064 * @cfg {String} bodyBorder @hide
1066 <div id="cfg-Ext.grid.GridPanel-bodyStyle"></div>/**
1067 * @cfg {String} bodyStyle @hide
1069 <div id="cfg-Ext.grid.GridPanel-contentEl"></div>/**
1070 * @cfg {String} contentEl @hide
1072 <div id="cfg-Ext.grid.GridPanel-disabledClass"></div>/**
1073 * @cfg {String} disabledClass @hide
1075 <div id="cfg-Ext.grid.GridPanel-elements"></div>/**
1076 * @cfg {String} elements @hide
1078 <div id="cfg-Ext.grid.GridPanel-html"></div>/**
1079 * @cfg {String} html @hide
1081 <div id="cfg-Ext.grid.GridPanel-preventBodyReset"></div>/**
1082 * @cfg {Boolean} preventBodyReset
1085 <div id="prop-Ext.grid.GridPanel-disabled"></div>/**
1086 * @property disabled
1089 <div id="method-Ext.grid.GridPanel-applyToMarkup"></div>/**
1090 * @method applyToMarkup
1093 <div id="method-Ext.grid.GridPanel-enable"></div>/**
1097 <div id="method-Ext.grid.GridPanel-disable"></div>/**
1101 <div id="method-Ext.grid.GridPanel-setDisabled"></div>/**
1102 * @method setDisabled
1106 Ext.reg('grid', Ext.grid.GridPanel);</pre>