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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.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,
109 <div id="cfg-Ext.grid.GridPanel-autoExpandMax"></div>/**
110 * @cfg {Number} autoExpandMax The maximum width the <tt>{@link #autoExpandColumn}</tt>
111 * can have (if enabled). Defaults to <tt>1000</tt>.
113 autoExpandMax : 1000,
115 <div id="cfg-Ext.grid.GridPanel-autoExpandMin"></div>/**
116 * @cfg {Number} autoExpandMin The minimum width the <tt>{@link #autoExpandColumn}</tt>
117 * can have (if enabled). Defaults to <tt>50</tt>.
121 <div id="cfg-Ext.grid.GridPanel-columnLines"></div>/**
122 * @cfg {Boolean} columnLines <tt>true</tt> to add css for column separation lines.
123 * Default is <tt>false</tt>.
127 <div id="cfg-Ext.grid.GridPanel-cm"></div>/**
128 * @cfg {Object} cm Shorthand for <tt>{@link #colModel}</tt>.
130 <div id="cfg-Ext.grid.GridPanel-colModel"></div>/**
131 * @cfg {Object} colModel The {@link Ext.grid.ColumnModel} to use when rendering the grid (required).
133 <div id="cfg-Ext.grid.GridPanel-columns"></div>/**
134 * @cfg {Array} columns An array of {@link Ext.grid.Column columns} to auto create a
135 * {@link Ext.grid.ColumnModel}. The ColumnModel may be explicitly created via the
136 * <tt>{@link #colModel}</tt> configuration property.
138 <div id="cfg-Ext.grid.GridPanel-ddGroup"></div>/**
139 * @cfg {String} ddGroup The DD group this GridPanel belongs to. Defaults to <tt>'GridDD'</tt> if not specified.
141 <div id="cfg-Ext.grid.GridPanel-ddText"></div>/**
142 * @cfg {String} ddText
143 * Configures the text in the drag proxy. Defaults to:
145 * ddText : '{0} selected row{1}'
147 * <tt>{0}</tt> is replaced with the number of selected rows.
149 ddText : '{0} selected row{1}',
151 <div id="cfg-Ext.grid.GridPanel-deferRowRender"></div>/**
152 * @cfg {Boolean} deferRowRender <P>Defaults to <tt>true</tt> to enable deferred row rendering.</p>
153 * <p>This allows the GridPanel to be initially rendered empty, with the expensive update of the row
154 * structure deferred so that layouts with GridPanels appear more quickly.</p>
156 deferRowRender : true,
158 <div id="cfg-Ext.grid.GridPanel-disableSelection"></div>/**
159 * @cfg {Boolean} disableSelection <p><tt>true</tt> to disable selections in the grid. Defaults to <tt>false</tt>.</p>
160 * <p>Ignored if a {@link #selModel SelectionModel} is specified.</p>
162 <div id="cfg-Ext.grid.GridPanel-enableColumnResize"></div>/**
163 * @cfg {Boolean} enableColumnResize <tt>false</tt> to turn off column resizing for the whole grid. Defaults to <tt>true</tt>.
165 <div id="cfg-Ext.grid.GridPanel-enableColumnHide"></div>/**
166 * @cfg {Boolean} enableColumnHide
167 * Defaults to <tt>true</tt> to enable {@link Ext.grid.Column#hidden hiding of columns}
168 * with the {@link #enableHdMenu header menu}.
170 enableColumnHide : true,
172 <div id="cfg-Ext.grid.GridPanel-enableColumnMove"></div>/**
173 * @cfg {Boolean} enableColumnMove Defaults to <tt>true</tt> to enable drag and drop reorder of columns. <tt>false</tt>
174 * to turn off column reordering via drag drop.
176 enableColumnMove : true,
178 <div id="cfg-Ext.grid.GridPanel-enableDragDrop"></div>/**
179 * @cfg {Boolean} enableDragDrop <p>Enables dragging of the selected rows of the GridPanel. Defaults to <tt>false</tt>.</p>
180 * <p>Setting this to <b><tt>true</tt></b> causes this GridPanel's {@link #getView GridView} to
181 * create an instance of {@link Ext.grid.GridDragZone}. <b>Note</b>: this is available only <b>after</b>
182 * the Grid has been rendered as the GridView's <tt>{@link Ext.grid.GridView#dragZone dragZone}</tt>
184 * <p>A cooperating {@link Ext.dd.DropZone DropZone} must be created who's implementations of
185 * {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
186 * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} are able
187 * to process the {@link Ext.grid.GridDragZone#getDragData data} which is provided.</p>
189 enableDragDrop : false,
191 <div id="cfg-Ext.grid.GridPanel-enableHdMenu"></div>/**
192 * @cfg {Boolean} enableHdMenu Defaults to <tt>true</tt> to enable the drop down button for menu in the headers.
196 <div id="cfg-Ext.grid.GridPanel-hideHeaders"></div>/**
197 * @cfg {Boolean} hideHeaders True to hide the grid's header. Defaults to <code>false</code>.
199 <div id="cfg-Ext.grid.GridPanel-loadMask"></div>/**
200 * @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the grid while
201 * loading. Defaults to <code>false</code>.
205 <div id="cfg-Ext.grid.GridPanel-maxHeight"></div>/**
206 * @cfg {Number} maxHeight Sets the maximum height of the grid - ignored if <tt>autoHeight</tt> is not on.
208 <div id="cfg-Ext.grid.GridPanel-minColumnWidth"></div>/**
209 * @cfg {Number} minColumnWidth The minimum width a column can be resized to. Defaults to <tt>25</tt>.
213 <div id="cfg-Ext.grid.GridPanel-sm"></div>/**
214 * @cfg {Object} sm Shorthand for <tt>{@link #selModel}</tt>.
216 <div id="cfg-Ext.grid.GridPanel-selModel"></div>/**
217 * @cfg {Object} selModel Any subclass of {@link Ext.grid.AbstractSelectionModel} that will provide
218 * the selection model for the grid (defaults to {@link Ext.grid.RowSelectionModel} if not specified).
220 <div id="cfg-Ext.grid.GridPanel-store"></div>/**
221 * @cfg {Ext.data.Store} store The {@link Ext.data.Store} the grid should use as its data source (required).
223 <div id="cfg-Ext.grid.GridPanel-stripeRows"></div>/**
224 * @cfg {Boolean} stripeRows <tt>true</tt> to stripe the rows. Default is <tt>false</tt>.
225 * <p>This causes the CSS class <tt><b>x-grid3-row-alt</b></tt> to be added to alternate rows of
226 * the grid. A default CSS rule is provided which sets a background colour, but you can override this
227 * with a rule which either overrides the <b>background-color</b> style using the '!important'
228 * modifier, or which uses a CSS selector of higher specificity.</p>
232 <div id="cfg-Ext.grid.GridPanel-trackMouseOver"></div>/**
233 * @cfg {Boolean} trackMouseOver True to highlight rows when the mouse is over. Default is <tt>true</tt>
234 * for GridPanel, but <tt>false</tt> for EditorGridPanel.
236 trackMouseOver : true,
238 <div id="cfg-Ext.grid.GridPanel-stateEvents"></div>/**
239 * @cfg {Array} stateEvents
240 * An array of events that, when fired, should trigger this component to save its state.
241 * Defaults to:<pre><code>
242 * stateEvents: ['columnmove', 'columnresize', 'sortchange', 'groupchange']
244 * <p>These can be any types of events supported by this component, including browser or
245 * custom events (e.g., <tt>['click', 'customerchange']</tt>).</p>
246 * <p>See {@link Ext.Component#stateful} for an explanation of saving and restoring
247 * Component state.</p>
249 stateEvents : ['columnmove', 'columnresize', 'sortchange', 'groupchange'],
251 <div id="cfg-Ext.grid.GridPanel-view"></div>/**
252 * @cfg {Object} view The {@link Ext.grid.GridView} used by the grid. This can be set
253 * before a call to {@link Ext.Component#render render()}.
257 <div id="cfg-Ext.grid.GridPanel-bubbleEvents"></div>/**
258 * @cfg {Array} bubbleEvents
259 * <p>An array of events that, when fired, should be bubbled to any parent container.
260 * See {@link Ext.util.Observable#enableBubble}.
261 * Defaults to <tt>[]</tt>.
265 <div id="cfg-Ext.grid.GridPanel-viewConfig"></div>/**
266 * @cfg {Object} viewConfig A config object that will be applied to the grid's UI view. Any of
267 * the config options available for {@link Ext.grid.GridView} can be specified here. This option
268 * is ignored if <tt>{@link #view}</tt> is specified.
278 initComponent : function() {
279 Ext.grid.GridPanel.superclass.initComponent.call(this);
281 if (this.columnLines) {
282 this.cls = (this.cls || '') + ' x-grid-with-col-lines';
284 // override any provided value since it isn't valid
285 // and is causing too many bug reports ;)
286 this.autoScroll = false;
287 this.autoWidth = false;
289 if(Ext.isArray(this.columns)){
290 this.colModel = new Ext.grid.ColumnModel(this.columns);
294 // check and correct shorthanded configs
296 this.store = this.ds;
300 this.colModel = this.cm;
304 this.selModel = this.sm;
307 this.store = Ext.StoreMgr.lookup(this.store);
311 <div id="event-Ext.grid.GridPanel-click"></div>/**
313 * The raw click event for the entire grid.
314 * @param {Ext.EventObject} e
317 <div id="event-Ext.grid.GridPanel-dblclick"></div>/**
319 * The raw dblclick event for the entire grid.
320 * @param {Ext.EventObject} e
323 <div id="event-Ext.grid.GridPanel-contextmenu"></div>/**
325 * The raw contextmenu event for the entire grid.
326 * @param {Ext.EventObject} e
329 <div id="event-Ext.grid.GridPanel-mousedown"></div>/**
331 * The raw mousedown event for the entire grid.
332 * @param {Ext.EventObject} e
335 <div id="event-Ext.grid.GridPanel-mouseup"></div>/**
337 * The raw mouseup event for the entire grid.
338 * @param {Ext.EventObject} e
341 <div id="event-Ext.grid.GridPanel-mouseover"></div>/**
343 * The raw mouseover event for the entire grid.
344 * @param {Ext.EventObject} e
347 <div id="event-Ext.grid.GridPanel-mouseout"></div>/**
349 * The raw mouseout event for the entire grid.
350 * @param {Ext.EventObject} e
353 <div id="event-Ext.grid.GridPanel-keypress"></div>/**
355 * The raw keypress event for the entire grid.
356 * @param {Ext.EventObject} e
359 <div id="event-Ext.grid.GridPanel-keydown"></div>/**
361 * The raw keydown event for the entire grid.
362 * @param {Ext.EventObject} e
367 <div id="event-Ext.grid.GridPanel-cellmousedown"></div>/**
368 * @event cellmousedown
369 * Fires before a cell is clicked
371 * @param {Number} rowIndex
372 * @param {Number} columnIndex
373 * @param {Ext.EventObject} e
376 <div id="event-Ext.grid.GridPanel-rowmousedown"></div>/**
377 * @event rowmousedown
378 * Fires before a row is clicked
380 * @param {Number} rowIndex
381 * @param {Ext.EventObject} e
384 <div id="event-Ext.grid.GridPanel-headermousedown"></div>/**
385 * @event headermousedown
386 * Fires before a header is clicked
388 * @param {Number} columnIndex
389 * @param {Ext.EventObject} e
393 <div id="event-Ext.grid.GridPanel-groupmousedown"></div>/**
394 * @event groupmousedown
395 * Fires before a group header is clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
397 * @param {String} groupField
398 * @param {String} groupValue
399 * @param {Ext.EventObject} e
403 <div id="event-Ext.grid.GridPanel-rowbodymousedown"></div>/**
404 * @event rowbodymousedown
405 * Fires before the row body is clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
407 * @param {Number} rowIndex
408 * @param {Ext.EventObject} e
412 <div id="event-Ext.grid.GridPanel-containermousedown"></div>/**
413 * @event containermousedown
414 * Fires before the container is clicked. The container consists of any part of the grid body that is not covered by a row.
416 * @param {Ext.EventObject} e
418 'containermousedown',
420 <div id="event-Ext.grid.GridPanel-cellclick"></div>/**
422 * Fires when a cell is clicked.
423 * The data for the cell is drawn from the {@link Ext.data.Record Record}
424 * for this row. To access the data in the listener function use the
425 * following technique:
427 function(grid, rowIndex, columnIndex, e) {
428 var record = grid.getStore().getAt(rowIndex); // Get the Record
429 var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
430 var data = record.get(fieldName);
434 * @param {Number} rowIndex
435 * @param {Number} columnIndex
436 * @param {Ext.EventObject} e
439 <div id="event-Ext.grid.GridPanel-celldblclick"></div>/**
440 * @event celldblclick
441 * Fires when a cell is double clicked
443 * @param {Number} rowIndex
444 * @param {Number} columnIndex
445 * @param {Ext.EventObject} e
448 <div id="event-Ext.grid.GridPanel-rowclick"></div>/**
450 * Fires when a row is clicked
452 * @param {Number} rowIndex
453 * @param {Ext.EventObject} e
456 <div id="event-Ext.grid.GridPanel-rowdblclick"></div>/**
458 * Fires when a row is double clicked
460 * @param {Number} rowIndex
461 * @param {Ext.EventObject} e
464 <div id="event-Ext.grid.GridPanel-headerclick"></div>/**
466 * Fires when a header is clicked
468 * @param {Number} columnIndex
469 * @param {Ext.EventObject} e
472 <div id="event-Ext.grid.GridPanel-headerdblclick"></div>/**
473 * @event headerdblclick
474 * Fires when a header cell is double clicked
476 * @param {Number} columnIndex
477 * @param {Ext.EventObject} e
480 <div id="event-Ext.grid.GridPanel-groupclick"></div>/**
482 * Fires when group header is clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
484 * @param {String} groupField
485 * @param {String} groupValue
486 * @param {Ext.EventObject} e
489 <div id="event-Ext.grid.GridPanel-groupdblclick"></div>/**
490 * @event groupdblclick
491 * Fires when group header is double clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
493 * @param {String} groupField
494 * @param {String} groupValue
495 * @param {Ext.EventObject} e
498 <div id="event-Ext.grid.GridPanel-containerclick"></div>/**
499 * @event containerclick
500 * Fires when the container is clicked. The container consists of any part of the grid body that is not covered by a row.
502 * @param {Ext.EventObject} e
505 <div id="event-Ext.grid.GridPanel-containerdblclick"></div>/**
506 * @event containerdblclick
507 * Fires when the container is double clicked. The container consists of any part of the grid body that is not covered by a row.
509 * @param {Ext.EventObject} e
513 <div id="event-Ext.grid.GridPanel-rowbodyclick"></div>/**
514 * @event rowbodyclick
515 * Fires when the row body is clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
517 * @param {Number} rowIndex
518 * @param {Ext.EventObject} e
521 <div id="event-Ext.grid.GridPanel-rowbodydblclick"></div>/**
522 * @event rowbodydblclick
523 * Fires when the row body is double clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
525 * @param {Number} rowIndex
526 * @param {Ext.EventObject} e
530 <div id="event-Ext.grid.GridPanel-rowcontextmenu"></div>/**
531 * @event rowcontextmenu
532 * Fires when a row is right clicked
534 * @param {Number} rowIndex
535 * @param {Ext.EventObject} e
538 <div id="event-Ext.grid.GridPanel-cellcontextmenu"></div>/**
539 * @event cellcontextmenu
540 * Fires when a cell is right clicked
542 * @param {Number} rowIndex
543 * @param {Number} cellIndex
544 * @param {Ext.EventObject} e
547 <div id="event-Ext.grid.GridPanel-headercontextmenu"></div>/**
548 * @event headercontextmenu
549 * Fires when a header is right clicked
551 * @param {Number} columnIndex
552 * @param {Ext.EventObject} e
555 <div id="event-Ext.grid.GridPanel-groupcontextmenu"></div>/**
556 * @event groupcontextmenu
557 * Fires when group header is right clicked. <b>Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}</b>.
559 * @param {String} groupField
560 * @param {String} groupValue
561 * @param {Ext.EventObject} e
564 <div id="event-Ext.grid.GridPanel-containercontextmenu"></div>/**
565 * @event containercontextmenu
566 * Fires when the container is right clicked. The container consists of any part of the grid body that is not covered by a row.
568 * @param {Ext.EventObject} e
570 'containercontextmenu',
571 <div id="event-Ext.grid.GridPanel-rowbodycontextmenu"></div>/**
572 * @event rowbodycontextmenu
573 * Fires when the row body is right clicked. <b>Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.</b>
575 * @param {Number} rowIndex
576 * @param {Ext.EventObject} e
578 'rowbodycontextmenu',
579 <div id="event-Ext.grid.GridPanel-bodyscroll"></div>/**
581 * Fires when the body element is scrolled
582 * @param {Number} scrollLeft
583 * @param {Number} scrollTop
586 <div id="event-Ext.grid.GridPanel-columnresize"></div>/**
587 * @event columnresize
588 * Fires when the user resizes a column
589 * @param {Number} columnIndex
590 * @param {Number} newSize
593 <div id="event-Ext.grid.GridPanel-columnmove"></div>/**
595 * Fires when the user moves a column
596 * @param {Number} oldIndex
597 * @param {Number} newIndex
600 <div id="event-Ext.grid.GridPanel-sortchange"></div>/**
602 * Fires when the grid's store sort changes
604 * @param {Object} sortInfo An object with the keys field and direction
607 <div id="event-Ext.grid.GridPanel-groupchange"></div>/**
609 * Fires when the grid's grouping changes (only applies for grids with a {@link Ext.grid.GroupingView GroupingView})
611 * @param {String} groupField A string with the grouping field, null if the store is not grouped.
614 <div id="event-Ext.grid.GridPanel-reconfigure"></div>/**
616 * Fires when the grid is reconfigured with a new store and/or column model.
618 * @param {Ext.data.Store} store The new store
619 * @param {Ext.grid.ColumnModel} colModel The new column model
622 <div id="event-Ext.grid.GridPanel-viewready"></div>/**
624 * Fires when the grid view is available (use this for selecting a default row).
632 onRender : function(ct, position){
633 Ext.grid.GridPanel.superclass.onRender.apply(this, arguments);
635 var c = this.getGridEl();
637 this.el.addClass('x-grid-panel');
641 mousedown: this.onMouseDown,
643 dblclick: this.onDblClick,
644 contextmenu: this.onContextMenu
647 this.relayEvents(c, ['mousedown','mouseup','mouseover','mouseout','keypress', 'keydown']);
649 var view = this.getView();
652 this.getSelectionModel().init(this);
656 initEvents : function(){
657 Ext.grid.GridPanel.superclass.initEvents.call(this);
660 this.loadMask = new Ext.LoadMask(this.bwrap,
661 Ext.apply({store:this.store}, this.loadMask));
665 initStateEvents : function(){
666 Ext.grid.GridPanel.superclass.initStateEvents.call(this);
667 this.mon(this.colModel, 'hiddenchange', this.saveState, this, {delay: 100});
670 applyState : function(state){
671 var cm = this.colModel,
679 for(var i = 0, len = cs.length; i < len; i++){
681 c = cm.getColumnById(s.id);
683 colIndex = cm.getIndexById(s.id);
684 cm.setState(colIndex, {
690 cm.moveColumn(colIndex, i);
698 store[store.remoteSort ? 'setDefaultSort' : 'sort'](s.field, s.direction);
705 store.clearGrouping();
710 var o = Ext.apply({}, state);
713 Ext.grid.GridPanel.superclass.applyState.call(this, o);
716 getState : function(){
717 var o = {columns: []},
722 for(var i = 0, c; (c = this.colModel.config[i]); i++){
728 o.columns[i].hidden = true;
731 o.columns[i].sortable = true;
735 ss = store.getSortState();
739 if(store.getGroupState){
740 gs = store.getGroupState();
750 afterRender : function(){
751 Ext.grid.GridPanel.superclass.afterRender.call(this);
753 this.on('bodyresize', v.layout, v);
755 if(this.deferRowRender){
756 if (!this.deferRowRenderTask){
757 this.deferRowRenderTask = new Ext.util.DelayedTask(v.afterRender, this.view);
759 this.deferRowRenderTask.delay(10);
763 this.viewReady = true;
766 <div id="method-Ext.grid.GridPanel-reconfigure"></div>/**
767 * <p>Reconfigures the grid to use a different Store and Column Model
768 * and fires the 'reconfigure' event. The View will be bound to the new
769 * objects and refreshed.</p>
770 * <p>Be aware that upon reconfiguring a GridPanel, certain existing settings <i>may</i> become
771 * invalidated. For example the configured {@link #autoExpandColumn} may no longer exist in the
772 * new ColumnModel. Also, an existing {@link Ext.PagingToolbar PagingToolbar} will still be bound
773 * to the old Store, and will need rebinding. Any {@link #plugins} might also need reconfiguring
774 * with the new data.</p>
775 * @param {Ext.data.Store} store The new {@link Ext.data.Store} object
776 * @param {Ext.grid.ColumnModel} colModel The new {@link Ext.grid.ColumnModel} object
778 reconfigure : function(store, colModel){
779 var rendered = this.rendered;
782 this.loadMask.destroy();
783 this.loadMask = new Ext.LoadMask(this.bwrap,
784 Ext.apply({}, {store:store}, this.initialConfig.loadMask));
788 this.view.initData(store, colModel);
791 this.colModel = colModel;
793 this.view.refresh(true);
795 this.fireEvent('reconfigure', this, store, colModel);
799 onDestroy : function(){
800 if (this.deferRowRenderTask && this.deferRowRenderTask.cancel){
801 this.deferRowRenderTask.cancel();
804 Ext.destroy(this.view, this.loadMask);
805 }else if(this.store && this.store.autoDestroy){
806 this.store.destroy();
808 Ext.destroy(this.colModel, this.selModel);
809 this.store = this.selModel = this.colModel = this.view = this.loadMask = null;
810 Ext.grid.GridPanel.superclass.onDestroy.call(this);
814 processEvent : function(name, e){
815 this.view.processEvent(name, e);
819 onClick : function(e){
820 this.processEvent('click', e);
824 onMouseDown : function(e){
825 this.processEvent('mousedown', e);
829 onContextMenu : function(e, t){
830 this.processEvent('contextmenu', e);
834 onDblClick : function(e){
835 this.processEvent('dblclick', e);
839 walkCells : function(row, col, step, fn, scope){
840 var cm = this.colModel,
841 clen = cm.getColumnCount(),
843 rlen = ds.getCount(),
857 if(fn.call(scope || this, row, col, cm) === true){
875 if(fn.call(scope || this, row, col, cm) === true){
886 <div id="method-Ext.grid.GridPanel-getGridEl"></div>/**
887 * Returns the grid's underlying element.
888 * @return {Element} The element
890 getGridEl : function(){
894 // private for compatibility, overridden by editor grid
895 stopEditing : Ext.emptyFn,
897 <div id="method-Ext.grid.GridPanel-getSelectionModel"></div>/**
898 * Returns the grid's selection model configured by the <code>{@link #selModel}</code>
899 * configuration option. If no selection model was configured, this will create
900 * and return a {@link Ext.grid.RowSelectionModel RowSelectionModel}.
901 * @return {SelectionModel}
903 getSelectionModel : function(){
905 this.selModel = new Ext.grid.RowSelectionModel(
906 this.disableSelection ? {selectRow: Ext.emptyFn} : null);
908 return this.selModel;
911 <div id="method-Ext.grid.GridPanel-getStore"></div>/**
912 * Returns the grid's data store.
913 * @return {Ext.data.Store} The store
915 getStore : function(){
919 <div id="method-Ext.grid.GridPanel-getColumnModel"></div>/**
920 * Returns the grid's ColumnModel.
921 * @return {Ext.grid.ColumnModel} The column model
923 getColumnModel : function(){
924 return this.colModel;
927 <div id="method-Ext.grid.GridPanel-getView"></div>/**
928 * Returns the grid's GridView object.
929 * @return {Ext.grid.GridView} The grid view
931 getView : function() {
933 this.view = new Ext.grid.GridView(this.viewConfig);
938 <div id="method-Ext.grid.GridPanel-getDragDropText"></div>/**
939 * Called to get grid's drag proxy text, by default returns this.ddText.
940 * @return {String} The text
942 getDragDropText : function(){
943 var count = this.selModel.getCount();
944 return String.format(this.ddText, count, count == 1 ? '' : 's');
947 <div id="cfg-Ext.grid.GridPanel-activeItem"></div>/**
948 * @cfg {String/Number} activeItem
951 <div id="cfg-Ext.grid.GridPanel-autoDestroy"></div>/**
952 * @cfg {Boolean} autoDestroy
955 <div id="cfg-Ext.grid.GridPanel-autoLoad"></div>/**
956 * @cfg {Object/String/Function} autoLoad
959 <div id="cfg-Ext.grid.GridPanel-autoWidth"></div>/**
960 * @cfg {Boolean} autoWidth
963 <div id="cfg-Ext.grid.GridPanel-bufferResize"></div>/**
964 * @cfg {Boolean/Number} bufferResize
967 <div id="cfg-Ext.grid.GridPanel-defaultType"></div>/**
968 * @cfg {String} defaultType
971 <div id="cfg-Ext.grid.GridPanel-defaults"></div>/**
972 * @cfg {Object} defaults
975 <div id="cfg-Ext.grid.GridPanel-hideBorders"></div>/**
976 * @cfg {Boolean} hideBorders
979 <div id="cfg-Ext.grid.GridPanel-items"></div>/**
983 <div id="cfg-Ext.grid.GridPanel-layout"></div>/**
984 * @cfg {String} layout
987 <div id="cfg-Ext.grid.GridPanel-layoutConfig"></div>/**
988 * @cfg {Object} layoutConfig
991 <div id="cfg-Ext.grid.GridPanel-monitorResize"></div>/**
992 * @cfg {Boolean} monitorResize
995 <div id="prop-Ext.grid.GridPanel-items"></div>/**
999 <div id="method-Ext.grid.GridPanel-add"></div>/**
1003 <div id="method-Ext.grid.GridPanel-cascade"></div>/**
1007 <div id="method-Ext.grid.GridPanel-doLayout"></div>/**
1011 <div id="method-Ext.grid.GridPanel-find"></div>/**
1015 <div id="method-Ext.grid.GridPanel-findBy"></div>/**
1019 <div id="method-Ext.grid.GridPanel-findById"></div>/**
1023 <div id="method-Ext.grid.GridPanel-findByType"></div>/**
1024 * @method findByType
1027 <div id="method-Ext.grid.GridPanel-getComponent"></div>/**
1028 * @method getComponent
1031 <div id="method-Ext.grid.GridPanel-getLayout"></div>/**
1035 <div id="method-Ext.grid.GridPanel-getUpdater"></div>/**
1036 * @method getUpdater
1039 <div id="method-Ext.grid.GridPanel-insert"></div>/**
1043 <div id="method-Ext.grid.GridPanel-load"></div>/**
1047 <div id="method-Ext.grid.GridPanel-remove"></div>/**
1051 <div id="event-Ext.grid.GridPanel-add"></div>/**
1055 <div id="event-Ext.grid.GridPanel-afterlayout"></div>/**
1056 * @event afterlayout
1059 <div id="event-Ext.grid.GridPanel-beforeadd"></div>/**
1063 <div id="event-Ext.grid.GridPanel-beforeremove"></div>/**
1064 * @event beforeremove
1067 <div id="event-Ext.grid.GridPanel-remove"></div>/**
1074 <div id="cfg-Ext.grid.GridPanel-allowDomMove"></div>/**
1075 * @cfg {String} allowDomMove @hide
1077 <div id="cfg-Ext.grid.GridPanel-autoEl"></div>/**
1078 * @cfg {String} autoEl @hide
1080 <div id="cfg-Ext.grid.GridPanel-applyTo"></div>/**
1081 * @cfg {String} applyTo @hide
1083 <div id="cfg-Ext.grid.GridPanel-autoScroll"></div>/**
1084 * @cfg {String} autoScroll @hide
1086 <div id="cfg-Ext.grid.GridPanel-bodyBorder"></div>/**
1087 * @cfg {String} bodyBorder @hide
1089 <div id="cfg-Ext.grid.GridPanel-bodyStyle"></div>/**
1090 * @cfg {String} bodyStyle @hide
1092 <div id="cfg-Ext.grid.GridPanel-contentEl"></div>/**
1093 * @cfg {String} contentEl @hide
1095 <div id="cfg-Ext.grid.GridPanel-disabledClass"></div>/**
1096 * @cfg {String} disabledClass @hide
1098 <div id="cfg-Ext.grid.GridPanel-elements"></div>/**
1099 * @cfg {String} elements @hide
1101 <div id="cfg-Ext.grid.GridPanel-html"></div>/**
1102 * @cfg {String} html @hide
1104 <div id="cfg-Ext.grid.GridPanel-preventBodyReset"></div>/**
1105 * @cfg {Boolean} preventBodyReset
1108 <div id="prop-Ext.grid.GridPanel-disabled"></div>/**
1109 * @property disabled
1112 <div id="method-Ext.grid.GridPanel-applyToMarkup"></div>/**
1113 * @method applyToMarkup
1116 <div id="method-Ext.grid.GridPanel-enable"></div>/**
1120 <div id="method-Ext.grid.GridPanel-disable"></div>/**
1124 <div id="method-Ext.grid.GridPanel-setDisabled"></div>/**
1125 * @method setDisabled
1129 Ext.reg('grid', Ext.grid.GridPanel);</pre>