3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.grid.GridPanel"></div>/**
\r
9 * @class Ext.grid.GridPanel
\r
10 * @extends Ext.Panel
\r
11 * <p>This class represents the primary interface of a component based grid control to represent data
\r
12 * in a tabular format of rows and columns. The GridPanel is composed of the following:</p>
\r
13 * <div class="mdetail-params"><ul>
\r
14 * <li><b>{@link Ext.data.Store Store}</b> : The Model holding the data records (rows)
\r
15 * <div class="sub-desc"></div></li>
\r
16 * <li><b>{@link Ext.grid.ColumnModel Column model}</b> : Column makeup
\r
17 * <div class="sub-desc"></div></li>
\r
18 * <li><b>{@link Ext.grid.GridView View}</b> : Encapsulates the user interface
\r
19 * <div class="sub-desc"></div></li>
\r
20 * <li><b>{@link Ext.grid.AbstractSelectionModel selection model}</b> : Selection behavior
\r
21 * <div class="sub-desc"></div></li>
\r
23 * <p>Example usage:</p>
\r
25 var grid = new Ext.grid.GridPanel({
\r
26 {@link #store}: new (@link Ext.data.Store}({
\r
27 {@link Ext.data.Store#autoDestroy autoDestroy}: true,
\r
28 {@link Ext.data.Store#reader reader}: reader,
\r
29 {@link Ext.data.Store#data data}: xg.dummyData
\r
32 {id: 'company', header: 'Company', width: 200, sortable: true, dataIndex: 'company'},
\r
33 {header: 'Price', width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
\r
34 {header: 'Change', width: 120, sortable: true, dataIndex: 'change'},
\r
35 {header: '% Change', width: 120, sortable: true, dataIndex: 'pctChange'},
\r
36 // instead of specifying renderer: Ext.util.Format.dateRenderer('m/d/Y') use xtype
\r
37 {header: 'Last Updated', width: 135, sortable: true, dataIndex: 'lastChange', xtype: 'datecolumn', format: 'M d, Y'}
\r
39 {@link #viewConfig}: {
\r
40 {@link Ext.grid.GridView#forceFit forceFit}: true,
\r
42 // Return CSS class to apply to rows depending upon data values
\r
43 {@link Ext.grid.GridView#getRowClass getRowClass}: function(record, index) {
\r
44 var c = record.{@link Ext.data.Record#get get}('change');
\r
46 return 'price-fall';
\r
48 return 'price-rise';
\r
52 {@link #sm}: new Ext.grid.RowSelectionModel({singleSelect:true}),
\r
56 title: 'Framed with Row Selection and Horizontal Scrolling',
\r
57 iconCls: 'icon-grid'
\r
60 * <p><b><u>Notes:</u></b></p>
\r
61 * <div class="mdetail-params"><ul>
\r
62 * <li>Although this class inherits many configuration options from base classes, some of them
\r
63 * (such as autoScroll, autoWidth, layout, items, etc) are not used by this class, and will
\r
64 * have no effect.</li>
\r
65 * <li>A grid <b>requires</b> a width in which to scroll its columns, and a height in which to
\r
66 * scroll its rows. These dimensions can either be set explicitly through the
\r
67 * <tt>{@link Ext.BoxComponent#height height}</tt> and <tt>{@link Ext.BoxComponent#width width}</tt>
\r
68 * configuration options or implicitly set by using the grid as a child item of a
\r
69 * {@link Ext.Container Container} which will have a {@link Ext.Container#layout layout manager}
\r
70 * provide the sizing of its child items (for example the Container of the Grid may specify
\r
71 * <tt>{@link Ext.Container#layout layout}:'fit'</tt>).</li>
\r
72 * <li>To access the data in a Grid, it is necessary to use the data model encapsulated
\r
73 * by the {@link #store Store}. See the {@link #cellclick} event for more details.</li>
\r
76 * @param {Object} config The config object
\r
79 Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
\r
80 <div id="cfg-Ext.grid.GridPanel-autoExpandColumn"></div>/**
\r
81 * @cfg {String} autoExpandColumn
\r
82 * <p>The <tt>{@link Ext.grid.Column#id id}</tt> of a {@link Ext.grid.Column column} in
\r
83 * this grid that should expand to fill unused space. This value specified here can not
\r
84 * be <tt>0</tt>.</p>
\r
85 * <br><p><b>Note</b>: If the Grid's {@link Ext.grid.GridView view} is configured with
\r
86 * <tt>{@link Ext.grid.GridView#forceFit forceFit}=true</tt> the <tt>autoExpandColumn</tt>
\r
87 * is ignored. See {@link Ext.grid.Column}.<tt>{@link Ext.grid.Column#width width}</tt>
\r
88 * for additional details.</p>
\r
89 * <p>See <tt>{@link #autoExpandMax}</tt> and <tt>{@link #autoExpandMin}</tt> also.</p>
\r
91 autoExpandColumn : false,
\r
92 <div id="cfg-Ext.grid.GridPanel-autoExpandMax"></div>/**
\r
93 * @cfg {Number} autoExpandMax The maximum width the <tt>{@link #autoExpandColumn}</tt>
\r
94 * can have (if enabled). Defaults to <tt>1000</tt>.
\r
96 autoExpandMax : 1000,
\r
97 <div id="cfg-Ext.grid.GridPanel-autoExpandMin"></div>/**
\r
98 * @cfg {Number} autoExpandMin The minimum width the <tt>{@link #autoExpandColumn}</tt>
\r
99 * can have (if enabled). Defaults to <tt>50</tt>.
\r
101 autoExpandMin : 50,
\r
102 <div id="cfg-Ext.grid.GridPanel-columnLines"></div>/**
\r
103 * @cfg {Boolean} columnLines <tt>true</tt> to add css for column separation lines.
\r
104 * Default is <tt>false</tt>.
\r
106 columnLines : false,
\r
107 <div id="cfg-Ext.grid.GridPanel-cm"></div>/**
\r
108 * @cfg {Object} cm Shorthand for <tt>{@link #colModel}</tt>.
\r
110 <div id="cfg-Ext.grid.GridPanel-colModel"></div>/**
\r
111 * @cfg {Object} colModel The {@link Ext.grid.ColumnModel} to use when rendering the grid (required).
\r
113 <div id="cfg-Ext.grid.GridPanel-columns"></div>/**
\r
114 * @cfg {Array} columns An array of {@link Ext.grid.Column columns} to auto create a
\r
115 * {@link Ext.grid.ColumnModel}. The ColumnModel may be explicitly created via the
\r
116 * <tt>{@link #colModel}</tt> configuration property.
\r
118 <div id="cfg-Ext.grid.GridPanel-ddGroup"></div>/**
\r
119 * @cfg {String} ddGroup The DD group this GridPanel belongs to. Defaults to <tt>'GridDD'</tt> if not specified.
\r
121 <div id="cfg-Ext.grid.GridPanel-ddText"></div>/**
\r
122 * @cfg {String} ddText
\r
123 * Configures the text in the drag proxy. Defaults to:
\r
125 * ddText : '{0} selected row{1}'
\r
127 * <tt>{0}</tt> is replaced with the number of selected rows.
\r
129 ddText : '{0} selected row{1}',
\r
130 <div id="cfg-Ext.grid.GridPanel-deferRowRender"></div>/**
\r
131 * @cfg {Boolean} deferRowRender <P>Defaults to <tt>true</tt> to enable deferred row rendering.</p>
\r
132 * <p>This allows the GridPanel to be initially rendered empty, with the expensive update of the row
\r
133 * structure deferred so that layouts with GridPanels appear more quickly.</p>
\r
135 deferRowRender : true,
\r
136 <div id="cfg-Ext.grid.GridPanel-disableSelection"></div>/**
\r
137 * @cfg {Boolean} disableSelection <p><tt>true</tt> to disable selections in the grid. Defaults to <tt>false</tt>.</p>
\r
138 * <p>Ignored if a {@link #selModel SelectionModel} is specified.</p>
\r
140 <div id="cfg-Ext.grid.GridPanel-enableColumnResize"></div>/**
\r
141 * @cfg {Boolean} enableColumnResize <tt>false</tt> to turn off column resizing for the whole grid. Defaults to <tt>true</tt>.
\r
143 <div id="cfg-Ext.grid.GridPanel-enableColumnHide"></div>/**
\r
144 * @cfg {Boolean} enableColumnHide Defaults to <tt>true</tt> to enable hiding of columns with the header context menu.
\r
146 enableColumnHide : true,
\r
147 <div id="cfg-Ext.grid.GridPanel-enableColumnMove"></div>/**
\r
148 * @cfg {Boolean} enableColumnMove Defaults to <tt>true</tt> to enable drag and drop reorder of columns. <tt>false</tt>
\r
149 * to turn off column reordering via drag drop.
\r
151 enableColumnMove : true,
\r
152 <div id="cfg-Ext.grid.GridPanel-enableDragDrop"></div>/**
\r
153 * @cfg {Boolean} enableDragDrop <p>Enables dragging of the selected rows of the GridPanel. Defaults to <tt>false</tt>.</p>
\r
154 * <p>Setting this to <b><tt>true</tt></b> causes this GridPanel's {@link #getView GridView} to
\r
155 * create an instance of {@link Ext.grid.GridDragZone}. <b>Note</b>: this is available only <b>after</b>
\r
156 * the Grid has been rendered as the GridView's <tt>{@link Ext.grid.GridView#dragZone dragZone}</tt>
\r
158 * <p>A cooperating {@link Ext.dd.DropZone DropZone} must be created who's implementations of
\r
159 * {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
\r
160 * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} are able
\r
161 * to process the {@link Ext.grid.GridDragZone#getDragData data} which is provided.</p>
\r
163 enableDragDrop : false,
\r
164 <div id="cfg-Ext.grid.GridPanel-enableHdMenu"></div>/**
\r
165 * @cfg {Boolean} enableHdMenu Defaults to <tt>true</tt> to enable the drop down button for menu in the headers.
\r
167 enableHdMenu : true,
\r
168 <div id="cfg-Ext.grid.GridPanel-hideHeaders"></div>/**
\r
169 * @cfg {Boolean} hideHeaders True to hide the grid's header. Defaults to <code>false</code>.
\r
171 <div id="cfg-Ext.grid.GridPanel-loadMask"></div>/**
\r
172 * @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the grid while
\r
173 * loading. Defaults to <code>false</code>.
\r
176 <div id="cfg-Ext.grid.GridPanel-maxHeight"></div>/**
\r
177 * @cfg {Number} maxHeight Sets the maximum height of the grid - ignored if <tt>autoHeight</tt> is not on.
\r
179 <div id="cfg-Ext.grid.GridPanel-minColumnWidth"></div>/**
\r
180 * @cfg {Number} minColumnWidth The minimum width a column can be resized to. Defaults to <tt>25</tt>.
\r
182 minColumnWidth : 25,
\r
183 <div id="cfg-Ext.grid.GridPanel-sm"></div>/**
\r
184 * @cfg {Object} sm Shorthand for <tt>{@link #selModel}</tt>.
\r
186 <div id="cfg-Ext.grid.GridPanel-selModel"></div>/**
\r
187 * @cfg {Object} selModel Any subclass of {@link Ext.grid.AbstractSelectionModel} that will provide
\r
188 * the selection model for the grid (defaults to {@link Ext.grid.RowSelectionModel} if not specified).
\r
190 <div id="cfg-Ext.grid.GridPanel-store"></div>/**
\r
191 * @cfg {Ext.data.Store} store The {@link Ext.data.Store} the grid should use as its data source (required).
\r
193 <div id="cfg-Ext.grid.GridPanel-stripeRows"></div>/**
\r
194 * @cfg {Boolean} stripeRows <tt>true</tt> to stripe the rows. Default is <tt>false</tt>.
\r
195 * <p>This causes the CSS class <tt><b>x-grid3-row-alt</b></tt> to be added to alternate rows of
\r
196 * the grid. A default CSS rule is provided which sets a background colour, but you can override this
\r
197 * with a rule which either overrides the <b>background-color</b> style using the '!important'
\r
198 * modifier, or which uses a CSS selector of higher specificity.</p>
\r
200 stripeRows : false,
\r
201 <div id="cfg-Ext.grid.GridPanel-trackMouseOver"></div>/**
\r
202 * @cfg {Boolean} trackMouseOver True to highlight rows when the mouse is over. Default is <tt>true</tt>
\r
203 * for GridPanel, but <tt>false</tt> for EditorGridPanel.
\r
205 trackMouseOver : true,
\r
206 <div id="cfg-Ext.grid.GridPanel-stateEvents"></div>/**
\r
207 * @cfg {Array} stateEvents
\r
208 * An array of events that, when fired, should trigger this component to save its state.
\r
209 * Defaults to:<pre><code>
\r
210 * stateEvents: ['columnmove', 'columnresize', 'sortchange']
\r
212 * <p>These can be any types of events supported by this component, including browser or
\r
213 * custom events (e.g., <tt>['click', 'customerchange']</tt>).</p>
\r
214 * <p>See {@link Ext.Component#stateful} for an explanation of saving and restoring
\r
215 * Component state.</p>
\r
217 stateEvents : ['columnmove', 'columnresize', 'sortchange'],
\r
218 <div id="cfg-Ext.grid.GridPanel-view"></div>/**
\r
219 * @cfg {Object} view The {@link Ext.grid.GridView} used by the grid. This can be set
\r
220 * before a call to {@link Ext.Component#render render()}.
\r
223 <div id="cfg-Ext.grid.GridPanel-viewConfig"></div>/**
\r
224 * @cfg {Object} viewConfig A config object that will be applied to the grid's UI view. Any of
\r
225 * the config options available for {@link Ext.grid.GridView} can be specified here. This option
\r
226 * is ignored if <tt>{@link #view}</tt> is specified.
\r
235 initComponent : function(){
\r
236 Ext.grid.GridPanel.superclass.initComponent.call(this);
\r
238 if(this.columnLines){
\r
239 this.cls = (this.cls || '') + ' x-grid-with-col-lines';
\r
241 // override any provided value since it isn't valid
\r
242 // and is causing too many bug reports ;)
\r
243 this.autoScroll = false;
\r
244 this.autoWidth = false;
\r
246 if(Ext.isArray(this.columns)){
\r
247 this.colModel = new Ext.grid.ColumnModel(this.columns);
\r
248 delete this.columns;
\r
251 // check and correct shorthanded configs
\r
253 this.store = this.ds;
\r
257 this.colModel = this.cm;
\r
261 this.selModel = this.sm;
\r
264 this.store = Ext.StoreMgr.lookup(this.store);
\r
268 <div id="event-Ext.grid.GridPanel-click"></div>/**
\r
270 * The raw click event for the entire grid.
\r
271 * @param {Ext.EventObject} e
\r
274 <div id="event-Ext.grid.GridPanel-dblclick"></div>/**
\r
276 * The raw dblclick event for the entire grid.
\r
277 * @param {Ext.EventObject} e
\r
280 <div id="event-Ext.grid.GridPanel-contextmenu"></div>/**
\r
281 * @event contextmenu
\r
282 * The raw contextmenu event for the entire grid.
\r
283 * @param {Ext.EventObject} e
\r
286 <div id="event-Ext.grid.GridPanel-mousedown"></div>/**
\r
288 * The raw mousedown event for the entire grid.
\r
289 * @param {Ext.EventObject} e
\r
292 <div id="event-Ext.grid.GridPanel-mouseup"></div>/**
\r
294 * The raw mouseup event for the entire grid.
\r
295 * @param {Ext.EventObject} e
\r
298 <div id="event-Ext.grid.GridPanel-mouseover"></div>/**
\r
300 * The raw mouseover event for the entire grid.
\r
301 * @param {Ext.EventObject} e
\r
304 <div id="event-Ext.grid.GridPanel-mouseout"></div>/**
\r
306 * The raw mouseout event for the entire grid.
\r
307 * @param {Ext.EventObject} e
\r
310 <div id="event-Ext.grid.GridPanel-keypress"></div>/**
\r
312 * The raw keypress event for the entire grid.
\r
313 * @param {Ext.EventObject} e
\r
316 <div id="event-Ext.grid.GridPanel-keydown"></div>/**
\r
318 * The raw keydown event for the entire grid.
\r
319 * @param {Ext.EventObject} e
\r
324 <div id="event-Ext.grid.GridPanel-cellmousedown"></div>/**
\r
325 * @event cellmousedown
\r
326 * Fires before a cell is clicked
\r
327 * @param {Grid} this
\r
328 * @param {Number} rowIndex
\r
329 * @param {Number} columnIndex
\r
330 * @param {Ext.EventObject} e
\r
333 <div id="event-Ext.grid.GridPanel-rowmousedown"></div>/**
\r
334 * @event rowmousedown
\r
335 * Fires before a row is clicked
\r
336 * @param {Grid} this
\r
337 * @param {Number} rowIndex
\r
338 * @param {Ext.EventObject} e
\r
341 <div id="event-Ext.grid.GridPanel-headermousedown"></div>/**
\r
342 * @event headermousedown
\r
343 * Fires before a header is clicked
\r
344 * @param {Grid} this
\r
345 * @param {Number} columnIndex
\r
346 * @param {Ext.EventObject} e
\r
350 <div id="event-Ext.grid.GridPanel-cellclick"></div>/**
\r
352 * Fires when a cell is clicked.
\r
353 * The data for the cell is drawn from the {@link Ext.data.Record Record}
\r
354 * for this row. To access the data in the listener function use the
\r
355 * following technique:
\r
357 function(grid, rowIndex, columnIndex, e) {
\r
358 var record = grid.getStore().getAt(rowIndex); // Get the Record
\r
359 var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
\r
360 var data = record.get(fieldName);
\r
363 * @param {Grid} this
\r
364 * @param {Number} rowIndex
\r
365 * @param {Number} columnIndex
\r
366 * @param {Ext.EventObject} e
\r
369 <div id="event-Ext.grid.GridPanel-celldblclick"></div>/**
\r
370 * @event celldblclick
\r
371 * Fires when a cell is double clicked
\r
372 * @param {Grid} this
\r
373 * @param {Number} rowIndex
\r
374 * @param {Number} columnIndex
\r
375 * @param {Ext.EventObject} e
\r
378 <div id="event-Ext.grid.GridPanel-rowclick"></div>/**
\r
380 * Fires when a row is clicked
\r
381 * @param {Grid} this
\r
382 * @param {Number} rowIndex
\r
383 * @param {Ext.EventObject} e
\r
386 <div id="event-Ext.grid.GridPanel-rowdblclick"></div>/**
\r
387 * @event rowdblclick
\r
388 * Fires when a row is double clicked
\r
389 * @param {Grid} this
\r
390 * @param {Number} rowIndex
\r
391 * @param {Ext.EventObject} e
\r
394 <div id="event-Ext.grid.GridPanel-headerclick"></div>/**
\r
395 * @event headerclick
\r
396 * Fires when a header is clicked
\r
397 * @param {Grid} this
\r
398 * @param {Number} columnIndex
\r
399 * @param {Ext.EventObject} e
\r
402 <div id="event-Ext.grid.GridPanel-headerdblclick"></div>/**
\r
403 * @event headerdblclick
\r
404 * Fires when a header cell is double clicked
\r
405 * @param {Grid} this
\r
406 * @param {Number} columnIndex
\r
407 * @param {Ext.EventObject} e
\r
410 <div id="event-Ext.grid.GridPanel-rowcontextmenu"></div>/**
\r
411 * @event rowcontextmenu
\r
412 * Fires when a row is right clicked
\r
413 * @param {Grid} this
\r
414 * @param {Number} rowIndex
\r
415 * @param {Ext.EventObject} e
\r
418 <div id="event-Ext.grid.GridPanel-cellcontextmenu"></div>/**
\r
419 * @event cellcontextmenu
\r
420 * Fires when a cell is right clicked
\r
421 * @param {Grid} this
\r
422 * @param {Number} rowIndex
\r
423 * @param {Number} cellIndex
\r
424 * @param {Ext.EventObject} e
\r
427 <div id="event-Ext.grid.GridPanel-headercontextmenu"></div>/**
\r
428 * @event headercontextmenu
\r
429 * Fires when a header is right clicked
\r
430 * @param {Grid} this
\r
431 * @param {Number} columnIndex
\r
432 * @param {Ext.EventObject} e
\r
434 'headercontextmenu',
\r
435 <div id="event-Ext.grid.GridPanel-bodyscroll"></div>/**
\r
436 * @event bodyscroll
\r
437 * Fires when the body element is scrolled
\r
438 * @param {Number} scrollLeft
\r
439 * @param {Number} scrollTop
\r
442 <div id="event-Ext.grid.GridPanel-columnresize"></div>/**
\r
443 * @event columnresize
\r
444 * Fires when the user resizes a column
\r
445 * @param {Number} columnIndex
\r
446 * @param {Number} newSize
\r
449 <div id="event-Ext.grid.GridPanel-columnmove"></div>/**
\r
450 * @event columnmove
\r
451 * Fires when the user moves a column
\r
452 * @param {Number} oldIndex
\r
453 * @param {Number} newIndex
\r
456 <div id="event-Ext.grid.GridPanel-sortchange"></div>/**
\r
457 * @event sortchange
\r
458 * Fires when the grid's store sort changes
\r
459 * @param {Grid} this
\r
460 * @param {Object} sortInfo An object with the keys field and direction
\r
463 <div id="event-Ext.grid.GridPanel-reconfigure"></div>/**
\r
464 * @event reconfigure
\r
465 * Fires when the grid is reconfigured with a new store and/or column model.
\r
466 * @param {Grid} this
\r
467 * @param {Ext.data.Store} store The new store
\r
468 * @param {Ext.grid.ColumnModel} colModel The new column model
\r
475 onRender : function(ct, position){
\r
476 Ext.grid.GridPanel.superclass.onRender.apply(this, arguments);
\r
480 this.el.addClass('x-grid-panel');
\r
482 var view = this.getView();
\r
486 mousedown: this.onMouseDown,
\r
487 click: this.onClick,
\r
488 dblclick: this.onDblClick,
\r
489 contextmenu: this.onContextMenu,
\r
490 keydown: this.onKeyDown,
\r
494 this.relayEvents(c, ['mousedown','mouseup','mouseover','mouseout','keypress']);
\r
496 this.getSelectionModel().init(this);
\r
497 this.view.render();
\r
501 initEvents : function(){
\r
502 Ext.grid.GridPanel.superclass.initEvents.call(this);
\r
505 this.loadMask = new Ext.LoadMask(this.bwrap,
\r
506 Ext.apply({store:this.store}, this.loadMask));
\r
510 initStateEvents : function(){
\r
511 Ext.grid.GridPanel.superclass.initStateEvents.call(this);
\r
512 this.mon(this.colModel, 'hiddenchange', this.saveState, this, {delay: 100});
\r
515 applyState : function(state){
\r
516 var cm = this.colModel;
\r
517 var cs = state.columns;
\r
519 for(var i = 0, len = cs.length; i < len; i++){
\r
521 var c = cm.getColumnById(s.id);
\r
523 c.hidden = s.hidden;
\r
525 var oldIndex = cm.getIndexById(s.id);
\r
527 cm.moveColumn(oldIndex, i);
\r
532 if(state.sort && this.store){
\r
533 this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
\r
535 delete state.columns;
\r
537 Ext.grid.GridPanel.superclass.applyState.call(this, state);
\r
540 getState : function(){
\r
541 var o = {columns: []};
\r
542 for(var i = 0, c; (c = this.colModel.config[i]); i++){
\r
548 o.columns[i].hidden = true;
\r
552 var ss = this.store.getSortState();
\r
561 afterRender : function(){
\r
562 Ext.grid.GridPanel.superclass.afterRender.call(this);
\r
563 this.view.layout();
\r
564 if(this.deferRowRender){
\r
565 this.view.afterRender.defer(10, this.view);
\r
567 this.view.afterRender();
\r
569 this.viewReady = true;
\r
572 <div id="method-Ext.grid.GridPanel-reconfigure"></div>/**
\r
573 * <p>Reconfigures the grid to use a different Store and Column Model
\r
574 * and fires the 'reconfigure' event. The View will be bound to the new
\r
575 * objects and refreshed.</p>
\r
576 * <p>Be aware that upon reconfiguring a GridPanel, certain existing settings <i>may</i> become
\r
577 * invalidated. For example the configured {@link #autoExpandColumn} may no longer exist in the
\r
578 * new ColumnModel. Also, an existing {@link Ext.PagingToolbar PagingToolbar} will still be bound
\r
579 * to the old Store, and will need rebinding. Any {@link #plugins} might also need reconfiguring
\r
580 * with the new data.</p>
\r
581 * @param {Ext.data.Store} store The new {@link Ext.data.Store} object
\r
582 * @param {Ext.grid.ColumnModel} colModel The new {@link Ext.grid.ColumnModel} object
\r
584 reconfigure : function(store, colModel){
\r
586 this.loadMask.destroy();
\r
587 this.loadMask = new Ext.LoadMask(this.bwrap,
\r
588 Ext.apply({}, {store:store}, this.initialConfig.loadMask));
\r
590 this.view.initData(store, colModel);
\r
591 this.store = store;
\r
592 this.colModel = colModel;
\r
594 this.view.refresh(true);
\r
596 this.fireEvent('reconfigure', this, store, colModel);
\r
600 onKeyDown : function(e){
\r
601 this.fireEvent('keydown', e);
\r
605 onDestroy : function(){
\r
608 c.removeAllListeners();
\r
610 Ext.destroy(this.view, this.loadMask);
\r
611 }else if(this.store && this.store.autoDestroy){
\r
612 this.store.destroy();
\r
614 Ext.destroy(this.colModel, this.selModel);
\r
615 this.store = this.selModel = this.colModel = this.view = this.loadMask = null;
\r
616 Ext.grid.GridPanel.superclass.onDestroy.call(this);
\r
620 processEvent : function(name, e){
\r
621 this.fireEvent(name, e);
\r
622 var t = e.getTarget();
\r
624 var header = v.findHeaderIndex(t);
\r
625 if(header !== false){
\r
626 this.fireEvent('header' + name, this, header, e);
\r
628 var row = v.findRowIndex(t);
\r
629 var cell = v.findCellIndex(t);
\r
631 this.fireEvent('row' + name, this, row, e);
\r
632 if(cell !== false){
\r
633 this.fireEvent('cell' + name, this, row, cell, e);
\r
640 onClick : function(e){
\r
641 this.processEvent('click', e);
\r
645 onMouseDown : function(e){
\r
646 this.processEvent('mousedown', e);
\r
650 onContextMenu : function(e, t){
\r
651 this.processEvent('contextmenu', e);
\r
655 onDblClick : function(e){
\r
656 this.processEvent('dblclick', e);
\r
660 walkCells : function(row, col, step, fn, scope){
\r
661 var cm = this.colModel, clen = cm.getColumnCount();
\r
662 var ds = this.store, rlen = ds.getCount(), first = true;
\r
674 if(fn.call(scope || this, row, col, cm) === true){
\r
692 if(fn.call(scope || this, row, col, cm) === true){
\r
704 onResize : function(){
\r
705 Ext.grid.GridPanel.superclass.onResize.apply(this, arguments);
\r
706 if(this.viewReady){
\r
707 this.view.layout();
\r
711 <div id="method-Ext.grid.GridPanel-getGridEl"></div>/**
\r
712 * Returns the grid's underlying element.
\r
713 * @return {Element} The element
\r
715 getGridEl : function(){
\r
719 // private for compatibility, overridden by editor grid
\r
720 stopEditing : Ext.emptyFn,
\r
722 <div id="method-Ext.grid.GridPanel-getSelectionModel"></div>/**
\r
723 * Returns the grid's selection model configured by the <code>{@link #selModel}</code>
\r
724 * configuration option. If no selection model was configured, this will create
\r
725 * and return a {@link Ext.grid.RowSelectionModel RowSelectionModel}.
\r
726 * @return {SelectionModel}
\r
728 getSelectionModel : function(){
\r
729 if(!this.selModel){
\r
730 this.selModel = new Ext.grid.RowSelectionModel(
\r
731 this.disableSelection ? {selectRow: Ext.emptyFn} : null);
\r
733 return this.selModel;
\r
736 <div id="method-Ext.grid.GridPanel-getStore"></div>/**
\r
737 * Returns the grid's data store.
\r
738 * @return {Ext.data.Store} The store
\r
740 getStore : function(){
\r
744 <div id="method-Ext.grid.GridPanel-getColumnModel"></div>/**
\r
745 * Returns the grid's ColumnModel.
\r
746 * @return {Ext.grid.ColumnModel} The column model
\r
748 getColumnModel : function(){
\r
749 return this.colModel;
\r
752 <div id="method-Ext.grid.GridPanel-getView"></div>/**
\r
753 * Returns the grid's GridView object.
\r
754 * @return {Ext.grid.GridView} The grid view
\r
756 getView : function(){
\r
758 this.view = new Ext.grid.GridView(this.viewConfig);
\r
762 <div id="method-Ext.grid.GridPanel-getDragDropText"></div>/**
\r
763 * Called to get grid's drag proxy text, by default returns this.ddText.
\r
764 * @return {String} The text
\r
766 getDragDropText : function(){
\r
767 var count = this.selModel.getCount();
\r
768 return String.format(this.ddText, count, count == 1 ? '' : 's');
\r
771 <div id="cfg-Ext.grid.GridPanel-activeItem"></div>/**
\r
772 * @cfg {String/Number} activeItem
\r
775 <div id="cfg-Ext.grid.GridPanel-autoDestroy"></div>/**
\r
776 * @cfg {Boolean} autoDestroy
\r
779 <div id="cfg-Ext.grid.GridPanel-autoLoad"></div>/**
\r
780 * @cfg {Object/String/Function} autoLoad
\r
783 <div id="cfg-Ext.grid.GridPanel-autoWidth"></div>/**
\r
784 * @cfg {Boolean} autoWidth
\r
787 <div id="cfg-Ext.grid.GridPanel-bufferResize"></div>/**
\r
788 * @cfg {Boolean/Number} bufferResize
\r
791 <div id="cfg-Ext.grid.GridPanel-defaultType"></div>/**
\r
792 * @cfg {String} defaultType
\r
795 <div id="cfg-Ext.grid.GridPanel-defaults"></div>/**
\r
796 * @cfg {Object} defaults
\r
799 <div id="cfg-Ext.grid.GridPanel-hideBorders"></div>/**
\r
800 * @cfg {Boolean} hideBorders
\r
803 <div id="cfg-Ext.grid.GridPanel-items"></div>/**
\r
804 * @cfg {Mixed} items
\r
807 <div id="cfg-Ext.grid.GridPanel-layout"></div>/**
\r
808 * @cfg {String} layout
\r
811 <div id="cfg-Ext.grid.GridPanel-layoutConfig"></div>/**
\r
812 * @cfg {Object} layoutConfig
\r
815 <div id="cfg-Ext.grid.GridPanel-monitorResize"></div>/**
\r
816 * @cfg {Boolean} monitorResize
\r
819 <div id="prop-Ext.grid.GridPanel-items"></div>/**
\r
823 <div id="method-Ext.grid.GridPanel-add"></div>/**
\r
827 <div id="method-Ext.grid.GridPanel-cascade"></div>/**
\r
831 <div id="method-Ext.grid.GridPanel-doLayout"></div>/**
\r
832 * @method doLayout
\r
835 <div id="method-Ext.grid.GridPanel-find"></div>/**
\r
839 <div id="method-Ext.grid.GridPanel-findBy"></div>/**
\r
843 <div id="method-Ext.grid.GridPanel-findById"></div>/**
\r
844 * @method findById
\r
847 <div id="method-Ext.grid.GridPanel-findByType"></div>/**
\r
848 * @method findByType
\r
851 <div id="method-Ext.grid.GridPanel-getComponent"></div>/**
\r
852 * @method getComponent
\r
855 <div id="method-Ext.grid.GridPanel-getLayout"></div>/**
\r
856 * @method getLayout
\r
859 <div id="method-Ext.grid.GridPanel-getUpdater"></div>/**
\r
860 * @method getUpdater
\r
863 <div id="method-Ext.grid.GridPanel-insert"></div>/**
\r
867 <div id="method-Ext.grid.GridPanel-load"></div>/**
\r
871 <div id="method-Ext.grid.GridPanel-remove"></div>/**
\r
875 <div id="event-Ext.grid.GridPanel-add"></div>/**
\r
879 <div id="event-Ext.grid.GridPanel-afterLayout"></div>/**
\r
880 * @event afterLayout
\r
883 <div id="event-Ext.grid.GridPanel-beforeadd"></div>/**
\r
884 * @event beforeadd
\r
887 <div id="event-Ext.grid.GridPanel-beforeremove"></div>/**
\r
888 * @event beforeremove
\r
891 <div id="event-Ext.grid.GridPanel-remove"></div>/**
\r
898 <div id="cfg-Ext.grid.GridPanel-allowDomMove"></div>/**
\r
899 * @cfg {String} allowDomMove @hide
\r
901 <div id="cfg-Ext.grid.GridPanel-autoEl"></div>/**
\r
902 * @cfg {String} autoEl @hide
\r
904 <div id="cfg-Ext.grid.GridPanel-applyTo"></div>/**
\r
905 * @cfg {String} applyTo @hide
\r
907 <div id="cfg-Ext.grid.GridPanel-autoScroll"></div>/**
\r
908 * @cfg {String} autoScroll @hide
\r
910 <div id="cfg-Ext.grid.GridPanel-bodyBorder"></div>/**
\r
911 * @cfg {String} bodyBorder @hide
\r
913 <div id="cfg-Ext.grid.GridPanel-bodyStyle"></div>/**
\r
914 * @cfg {String} bodyStyle @hide
\r
916 <div id="cfg-Ext.grid.GridPanel-contentEl"></div>/**
\r
917 * @cfg {String} contentEl @hide
\r
919 <div id="cfg-Ext.grid.GridPanel-disabledClass"></div>/**
\r
920 * @cfg {String} disabledClass @hide
\r
922 <div id="cfg-Ext.grid.GridPanel-elements"></div>/**
\r
923 * @cfg {String} elements @hide
\r
925 <div id="cfg-Ext.grid.GridPanel-html"></div>/**
\r
926 * @cfg {String} html @hide
\r
928 <div id="cfg-Ext.grid.GridPanel-preventBodyReset"></div>/**
\r
929 * @cfg {Boolean} preventBodyReset
\r
932 <div id="prop-Ext.grid.GridPanel-disabled"></div>/**
\r
933 * @property disabled
\r
936 <div id="method-Ext.grid.GridPanel-applyToMarkup"></div>/**
\r
937 * @method applyToMarkup
\r
940 <div id="method-Ext.grid.GridPanel-enable"></div>/**
\r
944 <div id="method-Ext.grid.GridPanel-disable"></div>/**
\r
948 <div id="method-Ext.grid.GridPanel-setDisabled"></div>/**
\r
949 * @method setDisabled
\r
953 Ext.reg('grid', Ext.grid.GridPanel);</pre>
\r