~cdparra/gelee/trunk

« back to all changes in this revision

Viewing changes to webui/ecosystem/extjs/source/widgets/grid/GridPanel.js

  • Committer: parra
  • Date: 2010-03-15 02:39:02 UTC
  • Revision ID: svn-v4:ac5bba68-f036-4e09-846e-8f32731cc928:trunk/gelee:1433
merged gelee at svn

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Ext JS Library 3.0 RC2
 
3
 * Copyright(c) 2006-2009, Ext JS, LLC.
 
4
 * licensing@extjs.com
 
5
 * 
 
6
 * http://extjs.com/license
 
7
 */
 
8
 
 
9
/**
 
10
 * @class Ext.grid.GridPanel
 
11
 * @extends Ext.Panel
 
12
 * <p>This class represents the primary interface of a component based grid control to represent data
 
13
 * in a tabular format of rows and columns. The GridPanel is composed of the following:</p>
 
14
 * <div class="mdetail-params"><ul>
 
15
 * <li><b>{@link Ext.data.Store Store}</b> : The Model holding the data records (rows)
 
16
 * <div class="sub-desc"></div></li>
 
17
 * <li><b>{@link Ext.grid.ColumnModel Column model}</b> : Column makeup
 
18
 * <div class="sub-desc"></div></li>
 
19
 * <li><b>{@link Ext.grid.GridView View}</b> : Encapsulates the user interface 
 
20
 * <div class="sub-desc"></div></li>
 
21
 * <li><b>{@link Ext.grid.AbstractSelectionModel selection model}</b> : Selection behavior 
 
22
 * <div class="sub-desc"></div></li>
 
23
 * </ul></div>
 
24
 * <p>Example usage:</p>
 
25
 * <pre><code>
 
26
var grid = new Ext.grid.GridPanel({
 
27
    {@link #store}: new (@link Ext.data.Store}({
 
28
        {@link Ext.data.Store#autoDestroy autoDestroy}: true,
 
29
        {@link Ext.data.Store#reader reader}: reader,
 
30
        {@link Ext.data.Store#data data}: xg.dummyData
 
31
    }),
 
32
    {@link #columns}: [
 
33
        {id: 'company', header: 'Company', width: 200, sortable: true, dataIndex: 'company'},
 
34
        {header: 'Price', width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
 
35
        {header: 'Change', width: 120, sortable: true, dataIndex: 'change'},
 
36
        {header: '% Change', width: 120, sortable: true, dataIndex: 'pctChange'},
 
37
        // instead of specifying renderer: Ext.util.Format.dateRenderer('m/d/Y') use xtype
 
38
        {header: 'Last Updated', width: 135, sortable: true, dataIndex: 'lastChange', xtype: 'datecolumn', format: 'M d, Y'}
 
39
    ],
 
40
    {@link #viewConfig}: {
 
41
        {@link Ext.grid.GridView#forceFit forceFit}: true,
 
42
 
 
43
//      Return CSS class to apply to rows depending upon data values
 
44
        {@link Ext.grid.GridView#getRowClass getRowClass}: function(record, index) {
 
45
            var c = record.{@link Ext.data.Record#get get}('change');
 
46
            if (c < 0) {
 
47
                return 'price-fall';
 
48
            } else if (c > 0) {
 
49
                return 'price-rise';
 
50
            }
 
51
        }
 
52
    },
 
53
    {@link #sm}: new Ext.grid.RowSelectionModel({singleSelect:true}),
 
54
    width: 600,
 
55
    height: 300,
 
56
    frame: true,
 
57
    title: 'Framed with Row Selection and Horizontal Scrolling',
 
58
    iconCls: 'icon-grid'
 
59
});
 
60
 * </code></pre>
 
61
 * <p><b><u>Notes:</u></b></p>
 
62
 * <div class="mdetail-params"><ul>
 
63
 * <li>Although this class inherits many configuration options from base classes, some of them
 
64
 * (such as autoScroll, autoWidth, layout, items, etc) are not used by this class, and will
 
65
 * have no effect.</li>
 
66
 * <li>A grid <b>requires</b> a width in which to scroll its columns, and a height in which to
 
67
 * scroll its rows. These dimensions can either be set explicitly through the
 
68
 * <tt>{@link Ext.BoxComponent#height height}</tt> and <tt>{@link Ext.BoxComponent#width width}</tt>
 
69
 * configuration options or implicitly set by using the grid as a child item of a
 
70
 * {@link Ext.Container Container} which will have a {@link Ext.Container#layout layout manager}
 
71
 * provide the sizing of its child items (for example the Container of the Grid may specify
 
72
 * <tt>{@link Ext.Container#layout layout}:'fit'</tt>).</li>
 
73
 * <li>To access the data in a Grid, it is necessary to use the data model encapsulated
 
74
 * by the {@link #store Store}. See the {@link #cellclick} event for more details.</li>
 
75
 * </ul></div>
 
76
 * @constructor
 
77
 * @param {Object} config The config object
 
78
 * @xtype grid
 
79
 */
 
80
Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
 
81
    /**
 
82
     * @cfg {String} autoExpandColumn
 
83
     * <p>The <tt>{@link Ext.grid.Column#id id}</tt> of a {@link Ext.grid.Column column} in
 
84
     * this grid that should expand to fill unused space. This value specified here can not
 
85
     * be <tt>0</tt>.</p>
 
86
     * <br><p><b>Note</b>: If the Grid's {@link Ext.grid.GridView view} is configured with
 
87
     * <tt>{@link Ext.grid.GridView#forceFit forceFit}=true</tt> the <tt>autoExpandColumn</tt>
 
88
     * is ignored. See {@link Ext.grid.Column}.<tt>{@link Ext.grid.Column#width width}</tt>
 
89
     * for additional details.</p>
 
90
     * <p>See <tt>{@link #autoExpandMax}</tt> and <tt>{@link #autoExpandMin}</tt> also.</p>
 
91
     */
 
92
    autoExpandColumn : false,
 
93
    /**
 
94
     * @cfg {Number} autoExpandMax The maximum width the <tt>{@link #autoExpandColumn}</tt>
 
95
     * can have (if enabled). Defaults to <tt>1000</tt>.
 
96
     */
 
97
    autoExpandMax : 1000,
 
98
    /**
 
99
     * @cfg {Number} autoExpandMin The minimum width the <tt>{@link #autoExpandColumn}</tt>
 
100
     * can have (if enabled). Defaults to <tt>50</tt>.
 
101
     */
 
102
    autoExpandMin : 50,
 
103
    /**
 
104
     * @cfg {Boolean} columnLines <tt>true</tt> to add css for column separation lines.
 
105
     * Default is <tt>false</tt>.
 
106
     */
 
107
    columnLines : false,
 
108
    /**
 
109
     * @cfg {Object} cm Shorthand for <tt>{@link #colModel}</tt>.
 
110
     */
 
111
    /**
 
112
     * @cfg {Object} colModel The {@link Ext.grid.ColumnModel} to use when rendering the grid (required).
 
113
     */
 
114
    /**
 
115
     * @cfg {Array} columns An array of {@link Ext.grid.Column columns} to auto create a
 
116
     * {@link Ext.grid.ColumnModel}.  The ColumnModel may be explicitly created via the
 
117
     * <tt>{@link #colModel}</tt> configuration property.
 
118
     */
 
119
    /**
 
120
     * @cfg {String} ddText
 
121
     * Configures the text in the drag proxy.  Defaults to:
 
122
     * <pre><code>
 
123
     * ddText : "{0} selected row{1}"
 
124
     * </code></pre>
 
125
     * <tt>{0}</tt> is replaced with the number of selected rows.
 
126
     */
 
127
    ddText : "{0} selected row{1}",
 
128
    /**
 
129
     * @cfg {Boolean} deferRowRender <P>Defaults to <tt>true</tt> to enable deferred row rendering.</p>
 
130
     * <p>This allows the GridPanel to be initially rendered empty, with the expensive update of the row
 
131
     * structure deferred so that layouts with GridPanels appear more quickly.</p>
 
132
     */
 
133
    deferRowRender : true,
 
134
    /**
 
135
     * @cfg {Boolean} disableSelection <p><tt>true</tt> to disable selections in the grid. Defaults to <tt>false</tt>.</p>
 
136
     * <p>Ignored if a {@link #selModel SelectionModel} is specified.</p>
 
137
     */
 
138
    /**
 
139
     * @cfg {Boolean} enableColumnResize <tt>false</tt> to turn off column resizing for the whole grid. Defaults to <tt>true</tt>.
 
140
     */
 
141
    /**
 
142
     * @cfg {Boolean} enableColumnHide Defaults to <tt>true</tt> to enable hiding of columns with the header context menu.
 
143
     */
 
144
    enableColumnHide : true,
 
145
    /**
 
146
     * @cfg {Boolean} enableColumnMove Defaults to <tt>true</tt> to enable drag and drop reorder of columns. <tt>false</tt>
 
147
     * to turn off column reordering via drag drop.
 
148
     */
 
149
    enableColumnMove : true,
 
150
    /**
 
151
     * @cfg {Boolean} enableDragDrop <p>Enables dragging of the selected rows of the GridPanel. Defaults to <tt>false</tt>.</p>
 
152
     * <p>Setting this to <b><tt>true</tt></b> causes this GridPanel's {@link #getView GridView} to
 
153
     * create an instance of {@link Ext.grid.GridDragZone}. <b>Note</b>: this is available only <b>after</b>
 
154
     * the Grid has been rendered as the GridView's <tt>{@link Ext.grid.GridView#dragZone dragZone}</tt>
 
155
     * property.</p>
 
156
     * <p>A cooperating {@link Ext.dd.DropZone DropZone} must be created who's implementations of
 
157
     * {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
 
158
     * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} are able
 
159
     * to process the {@link Ext.grid.GridDragZone#getDragData data} which is provided.</p>
 
160
     */
 
161
    enableDragDrop : false,
 
162
    /**
 
163
     * @cfg {Boolean} enableHdMenu Defaults to <tt>true</tt> to enable the drop down button for menu in the headers.
 
164
     */
 
165
    enableHdMenu : true,
 
166
    /**
 
167
     * @cfg {Boolean} hideHeaders True to hide the grid's header. Defaults to <code>false</code>.
 
168
     */
 
169
    /**
 
170
     * @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the grid while
 
171
     * loading. Defaults to <code>false</code>.
 
172
     */
 
173
    loadMask : false,
 
174
    /**
 
175
     * @cfg {Number} maxHeight Sets the maximum height of the grid - ignored if <tt>autoHeight</tt> is not on.
 
176
     */
 
177
    /**
 
178
     * @cfg {Number} minColumnWidth The minimum width a column can be resized to. Defaults to <tt>25</tt>.
 
179
     */
 
180
    minColumnWidth : 25,
 
181
    /**
 
182
     * @cfg {Object} sm Shorthand for <tt>{@link #selModel}</tt>.
 
183
     */
 
184
    /**
 
185
     * @cfg {Object} selModel Any subclass of {@link Ext.grid.AbstractSelectionModel} that will provide
 
186
     * the selection model for the grid (defaults to {@link Ext.grid.RowSelectionModel} if not specified).
 
187
     */
 
188
    /**
 
189
     * @cfg {Ext.data.Store} store The {@link Ext.data.Store} the grid should use as its data source (required).
 
190
     */
 
191
    /**
 
192
     * @cfg {Boolean} stripeRows <tt>true</tt> to stripe the rows. Default is <tt>false</tt>.
 
193
     * <p>This causes the CSS class <tt><b>x-grid3-row-alt</b></tt> to be added to alternate rows of
 
194
     * the grid. A default CSS rule is provided which sets a background colour, but you can override this
 
195
     * with a rule which either overrides the <b>background-color</b> style using the "!important"
 
196
     * modifier, or which uses a CSS selector of higher specificity.</p>
 
197
     */
 
198
    stripeRows : false,
 
199
    /**
 
200
     * @cfg {Boolean} trackMouseOver True to highlight rows when the mouse is over. Default is <tt>true</tt>
 
201
     * for GridPanel, but <tt>false</tt> for EditorGridPanel.
 
202
     */
 
203
    trackMouseOver : true,
 
204
    /**
 
205
     * @cfg {Array} stateEvents
 
206
     * An array of events that, when fired, should trigger this component to save its state.
 
207
     * Defaults to:<pre><code>
 
208
     * stateEvents: ["columnmove", "columnresize", "sortchange"]
 
209
     * </code></pre>
 
210
     * <p>These can be any types of events supported by this component, including browser or
 
211
     * custom events (e.g., <tt>['click', 'customerchange']</tt>).</p>
 
212
     * <p>See {@link Ext.Component#stateful} for an explanation of saving and restoring
 
213
     * Component state.</p>
 
214
     */
 
215
    stateEvents : ["columnmove", "columnresize", "sortchange"],
 
216
    /**
 
217
     * @cfg {Object} view The {@link Ext.grid.GridView} used by the grid. This can be set
 
218
     * before a call to {@link Ext.Component#render render()}.
 
219
     */
 
220
    view : null,
 
221
    /**
 
222
     * @cfg {Object} viewConfig A config object that will be applied to the grid's UI view.  Any of
 
223
     * the config options available for {@link Ext.grid.GridView} can be specified here. This option
 
224
     * is ignored if <tt>{@link #view}</tt> is specified.
 
225
     */
 
226
 
 
227
    // private
 
228
    rendered : false,
 
229
    // private
 
230
    viewReady : false,
 
231
 
 
232
    // private
 
233
    initComponent : function(){
 
234
        Ext.grid.GridPanel.superclass.initComponent.call(this);
 
235
 
 
236
        if(this.columnLines){
 
237
            this.cls = (this.cls || '') + ' x-grid-with-col-lines';
 
238
        }
 
239
        // override any provided value since it isn't valid
 
240
        // and is causing too many bug reports ;)
 
241
        this.autoScroll = false;
 
242
        this.autoWidth = false;
 
243
 
 
244
        if(Ext.isArray(this.columns)){
 
245
            this.colModel = new Ext.grid.ColumnModel(this.columns);
 
246
            delete this.columns;
 
247
        }
 
248
 
 
249
        // check and correct shorthanded configs
 
250
        if(this.ds){
 
251
            this.store = this.ds;
 
252
            delete this.ds;
 
253
        }
 
254
        if(this.cm){
 
255
            this.colModel = this.cm;
 
256
            delete this.cm;
 
257
        }
 
258
        if(this.sm){
 
259
            this.selModel = this.sm;
 
260
            delete this.sm;
 
261
        }
 
262
        this.store = Ext.StoreMgr.lookup(this.store);
 
263
 
 
264
        this.addEvents(
 
265
            // raw events
 
266
            /**
 
267
             * @event click
 
268
             * The raw click event for the entire grid.
 
269
             * @param {Ext.EventObject} e
 
270
             */
 
271
            "click",
 
272
            /**
 
273
             * @event dblclick
 
274
             * The raw dblclick event for the entire grid.
 
275
             * @param {Ext.EventObject} e
 
276
             */
 
277
            "dblclick",
 
278
            /**
 
279
             * @event contextmenu
 
280
             * The raw contextmenu event for the entire grid.
 
281
             * @param {Ext.EventObject} e
 
282
             */
 
283
            "contextmenu",
 
284
            /**
 
285
             * @event mousedown
 
286
             * The raw mousedown event for the entire grid.
 
287
             * @param {Ext.EventObject} e
 
288
             */
 
289
            "mousedown",
 
290
            /**
 
291
             * @event mouseup
 
292
             * The raw mouseup event for the entire grid.
 
293
             * @param {Ext.EventObject} e
 
294
             */
 
295
            "mouseup",
 
296
            /**
 
297
             * @event mouseover
 
298
             * The raw mouseover event for the entire grid.
 
299
             * @param {Ext.EventObject} e
 
300
             */
 
301
            "mouseover",
 
302
            /**
 
303
             * @event mouseout
 
304
             * The raw mouseout event for the entire grid.
 
305
             * @param {Ext.EventObject} e
 
306
             */
 
307
            "mouseout",
 
308
            /**
 
309
             * @event keypress
 
310
             * The raw keypress event for the entire grid.
 
311
             * @param {Ext.EventObject} e
 
312
             */
 
313
            "keypress",
 
314
            /**
 
315
             * @event keydown
 
316
             * The raw keydown event for the entire grid.
 
317
             * @param {Ext.EventObject} e
 
318
             */
 
319
            "keydown",
 
320
 
 
321
            // custom events
 
322
            /**
 
323
             * @event cellmousedown
 
324
             * Fires before a cell is clicked
 
325
             * @param {Grid} this
 
326
             * @param {Number} rowIndex
 
327
             * @param {Number} columnIndex
 
328
             * @param {Ext.EventObject} e
 
329
             */
 
330
            "cellmousedown",
 
331
            /**
 
332
             * @event rowmousedown
 
333
             * Fires before a row is clicked
 
334
             * @param {Grid} this
 
335
             * @param {Number} rowIndex
 
336
             * @param {Ext.EventObject} e
 
337
             */
 
338
            "rowmousedown",
 
339
            /**
 
340
             * @event headermousedown
 
341
             * Fires before a header is clicked
 
342
             * @param {Grid} this
 
343
             * @param {Number} columnIndex
 
344
             * @param {Ext.EventObject} e
 
345
             */
 
346
            "headermousedown",
 
347
 
 
348
            /**
 
349
             * @event cellclick
 
350
             * Fires when a cell is clicked.
 
351
             * The data for the cell is drawn from the {@link Ext.data.Record Record}
 
352
             * for this row. To access the data in the listener function use the
 
353
             * following technique:
 
354
             * <pre><code>
 
355
function(grid, rowIndex, columnIndex, e) {
 
356
    var record = grid.getStore().getAt(rowIndex);  // Get the Record
 
357
    var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
 
358
    var data = record.get(fieldName);
 
359
}
 
360
</code></pre>
 
361
             * @param {Grid} this
 
362
             * @param {Number} rowIndex
 
363
             * @param {Number} columnIndex
 
364
             * @param {Ext.EventObject} e
 
365
             */
 
366
            "cellclick",
 
367
            /**
 
368
             * @event celldblclick
 
369
             * Fires when a cell is double clicked
 
370
             * @param {Grid} this
 
371
             * @param {Number} rowIndex
 
372
             * @param {Number} columnIndex
 
373
             * @param {Ext.EventObject} e
 
374
             */
 
375
            "celldblclick",
 
376
            /**
 
377
             * @event rowclick
 
378
             * Fires when a row is clicked
 
379
             * @param {Grid} this
 
380
             * @param {Number} rowIndex
 
381
             * @param {Ext.EventObject} e
 
382
             */
 
383
            "rowclick",
 
384
            /**
 
385
             * @event rowdblclick
 
386
             * Fires when a row is double clicked
 
387
             * @param {Grid} this
 
388
             * @param {Number} rowIndex
 
389
             * @param {Ext.EventObject} e
 
390
             */
 
391
            "rowdblclick",
 
392
            /**
 
393
             * @event headerclick
 
394
             * Fires when a header is clicked
 
395
             * @param {Grid} this
 
396
             * @param {Number} columnIndex
 
397
             * @param {Ext.EventObject} e
 
398
             */
 
399
            "headerclick",
 
400
            /**
 
401
             * @event headerdblclick
 
402
             * Fires when a header cell is double clicked
 
403
             * @param {Grid} this
 
404
             * @param {Number} columnIndex
 
405
             * @param {Ext.EventObject} e
 
406
             */
 
407
            "headerdblclick",
 
408
            /**
 
409
             * @event rowcontextmenu
 
410
             * Fires when a row is right clicked
 
411
             * @param {Grid} this
 
412
             * @param {Number} rowIndex
 
413
             * @param {Ext.EventObject} e
 
414
             */
 
415
            "rowcontextmenu",
 
416
            /**
 
417
             * @event cellcontextmenu
 
418
             * Fires when a cell is right clicked
 
419
             * @param {Grid} this
 
420
             * @param {Number} rowIndex
 
421
             * @param {Number} cellIndex
 
422
             * @param {Ext.EventObject} e
 
423
             */
 
424
            "cellcontextmenu",
 
425
            /**
 
426
             * @event headercontextmenu
 
427
             * Fires when a header is right clicked
 
428
             * @param {Grid} this
 
429
             * @param {Number} columnIndex
 
430
             * @param {Ext.EventObject} e
 
431
             */
 
432
            "headercontextmenu",
 
433
            /**
 
434
             * @event bodyscroll
 
435
             * Fires when the body element is scrolled
 
436
             * @param {Number} scrollLeft
 
437
             * @param {Number} scrollTop
 
438
             */
 
439
            "bodyscroll",
 
440
            /**
 
441
             * @event columnresize
 
442
             * Fires when the user resizes a column
 
443
             * @param {Number} columnIndex
 
444
             * @param {Number} newSize
 
445
             */
 
446
            "columnresize",
 
447
            /**
 
448
             * @event columnmove
 
449
             * Fires when the user moves a column
 
450
             * @param {Number} oldIndex
 
451
             * @param {Number} newIndex
 
452
             */
 
453
            "columnmove",
 
454
            /**
 
455
             * @event sortchange
 
456
             * Fires when the grid's store sort changes
 
457
             * @param {Grid} this
 
458
             * @param {Object} sortInfo An object with the keys field and direction
 
459
             */
 
460
            "sortchange"
 
461
        );
 
462
    },
 
463
 
 
464
    // private
 
465
    onRender : function(ct, position){
 
466
        Ext.grid.GridPanel.superclass.onRender.apply(this, arguments);
 
467
 
 
468
        var c = this.body;
 
469
 
 
470
        this.el.addClass('x-grid-panel');
 
471
 
 
472
        var view = this.getView();
 
473
        view.init(this);
 
474
 
 
475
        this.mon(c, {
 
476
            mousedown: this.onMouseDown,
 
477
            click: this.onClick,
 
478
            dblclick: this.onDblClick,
 
479
            contextmenu: this.onContextMenu,
 
480
            keydown: this.onKeyDown,
 
481
            scope: this
 
482
        })
 
483
 
 
484
        this.relayEvents(c, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
 
485
 
 
486
        this.getSelectionModel().init(this);
 
487
        this.view.render();
 
488
    },
 
489
 
 
490
    // private
 
491
    initEvents : function(){
 
492
        Ext.grid.GridPanel.superclass.initEvents.call(this);
 
493
 
 
494
        if(this.loadMask){
 
495
            this.loadMask = new Ext.LoadMask(this.bwrap,
 
496
                    Ext.apply({store:this.store}, this.loadMask));
 
497
        }
 
498
    },
 
499
 
 
500
    initStateEvents : function(){
 
501
        Ext.grid.GridPanel.superclass.initStateEvents.call(this);
 
502
        this.mon(this.colModel, 'hiddenchange', this.saveState, this, {delay: 100});
 
503
    },
 
504
 
 
505
    applyState : function(state){
 
506
        var cm = this.colModel;
 
507
        var cs = state.columns;
 
508
        if(cs){
 
509
            for(var i = 0, len = cs.length; i < len; i++){
 
510
                var s = cs[i];
 
511
                var c = cm.getColumnById(s.id);
 
512
                if(c){
 
513
                    c.hidden = s.hidden;
 
514
                    c.width = s.width;
 
515
                    var oldIndex = cm.getIndexById(s.id);
 
516
                    if(oldIndex != i){
 
517
                        cm.moveColumn(oldIndex, i);
 
518
                    }
 
519
                }
 
520
            }
 
521
        }
 
522
        if(state.sort && this.store){
 
523
            this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
 
524
        }
 
525
        delete state.columns;
 
526
        delete state.sort;
 
527
        Ext.grid.GridPanel.superclass.applyState.call(this, state);
 
528
    },
 
529
 
 
530
    getState : function(){
 
531
        var o = {columns: []};
 
532
        for(var i = 0, c; c = this.colModel.config[i]; i++){
 
533
            o.columns[i] = {
 
534
                id: c.id,
 
535
                width: c.width
 
536
            };
 
537
            if(c.hidden){
 
538
                o.columns[i].hidden = true;
 
539
            }
 
540
        }
 
541
        if(this.store){
 
542
            var ss = this.store.getSortState();
 
543
            if(ss){
 
544
                o.sort = ss;
 
545
            }
 
546
        }
 
547
        return o;
 
548
    },
 
549
 
 
550
    // private
 
551
    afterRender : function(){
 
552
        Ext.grid.GridPanel.superclass.afterRender.call(this);
 
553
        this.view.layout();
 
554
        if(this.deferRowRender){
 
555
            this.view.afterRender.defer(10, this.view);
 
556
        }else{
 
557
            this.view.afterRender();
 
558
        }
 
559
        this.viewReady = true;
 
560
    },
 
561
 
 
562
    /**
 
563
     * <p>Reconfigures the grid to use a different Store and Column Model.
 
564
     * The View will be bound to the new objects and refreshed.</p>
 
565
     * <p>Be aware that upon reconfiguring a GridPanel, certain existing settings <i>may</i> become
 
566
     * invalidated. For example the configured {@link #autoExpandColumn} may no longer exist in the
 
567
     * new ColumnModel. Also, an existing {@link Ext.PagingToolbar PagingToolbar} will still be bound
 
568
     * to the old Store, and will need rebinding. Any {@link #plugins} might also need reconfiguring
 
569
     * with the new data.</p>
 
570
     * @param {Ext.data.Store} store The new {@link Ext.data.Store} object
 
571
     * @param {Ext.grid.ColumnModel} colModel The new {@link Ext.grid.ColumnModel} object
 
572
     */
 
573
    reconfigure : function(store, colModel){
 
574
        if(this.loadMask){
 
575
            this.loadMask.destroy();
 
576
            this.loadMask = new Ext.LoadMask(this.bwrap,
 
577
                    Ext.apply({}, {store:store}, this.initialConfig.loadMask));
 
578
        }
 
579
        this.view.initData(store, colModel);
 
580
        this.store = store;
 
581
        this.colModel = colModel;
 
582
        if(this.rendered){
 
583
            this.view.refresh(true);
 
584
        }
 
585
    },
 
586
 
 
587
    // private
 
588
    onKeyDown : function(e){
 
589
        this.fireEvent("keydown", e);
 
590
    },
 
591
 
 
592
    // private
 
593
    onDestroy : function(){
 
594
        if(this.rendered){
 
595
            var c = this.body;
 
596
            c.removeAllListeners();
 
597
            c.update("");
 
598
            Ext.destroy(this.view, this.loadMask);
 
599
        }else if(this.store && this.store.autoDestroy){
 
600
            this.store.destroy();
 
601
        }
 
602
        Ext.destroy(this.colModel);
 
603
        this.store = this.colModel = this.view = this.loadMask = null;
 
604
        Ext.grid.GridPanel.superclass.onDestroy.call(this);
 
605
    },
 
606
 
 
607
    // private
 
608
    processEvent : function(name, e){
 
609
        this.fireEvent(name, e);
 
610
        var t = e.getTarget();
 
611
        var v = this.view;
 
612
        var header = v.findHeaderIndex(t);
 
613
        if(header !== false){
 
614
            this.fireEvent("header" + name, this, header, e);
 
615
        }else{
 
616
            var row = v.findRowIndex(t);
 
617
            var cell = v.findCellIndex(t);
 
618
            if(row !== false){
 
619
                this.fireEvent("row" + name, this, row, e);
 
620
                if(cell !== false){
 
621
                    this.fireEvent("cell" + name, this, row, cell, e);
 
622
                }
 
623
            }
 
624
        }
 
625
    },
 
626
 
 
627
    // private
 
628
    onClick : function(e){
 
629
        this.processEvent("click", e);
 
630
    },
 
631
 
 
632
    // private
 
633
    onMouseDown : function(e){
 
634
        this.processEvent("mousedown", e);
 
635
    },
 
636
 
 
637
    // private
 
638
    onContextMenu : function(e, t){
 
639
        this.processEvent("contextmenu", e);
 
640
    },
 
641
 
 
642
    // private
 
643
    onDblClick : function(e){
 
644
        this.processEvent("dblclick", e);
 
645
    },
 
646
 
 
647
    // private
 
648
    walkCells : function(row, col, step, fn, scope){
 
649
        var cm = this.colModel, clen = cm.getColumnCount();
 
650
        var ds = this.store, rlen = ds.getCount(), first = true;
 
651
        if(step < 0){
 
652
            if(col < 0){
 
653
                row--;
 
654
                first = false;
 
655
            }
 
656
            while(row >= 0){
 
657
                if(!first){
 
658
                    col = clen-1;
 
659
                }
 
660
                first = false;
 
661
                while(col >= 0){
 
662
                    if(fn.call(scope || this, row, col, cm) === true){
 
663
                        return [row, col];
 
664
                    }
 
665
                    col--;
 
666
                }
 
667
                row--;
 
668
            }
 
669
        } else {
 
670
            if(col >= clen){
 
671
                row++;
 
672
                first = false;
 
673
            }
 
674
            while(row < rlen){
 
675
                if(!first){
 
676
                    col = 0;
 
677
                }
 
678
                first = false;
 
679
                while(col < clen){
 
680
                    if(fn.call(scope || this, row, col, cm) === true){
 
681
                        return [row, col];
 
682
                    }
 
683
                    col++;
 
684
                }
 
685
                row++;
 
686
            }
 
687
        }
 
688
        return null;
 
689
    },
 
690
 
 
691
    // private
 
692
    onResize : function(){
 
693
        Ext.grid.GridPanel.superclass.onResize.apply(this, arguments);
 
694
        if(this.viewReady){
 
695
            this.view.layout();
 
696
        }
 
697
    },
 
698
 
 
699
    /**
 
700
     * Returns the grid's underlying element.
 
701
     * @return {Element} The element
 
702
     */
 
703
    getGridEl : function(){
 
704
        return this.body;
 
705
    },
 
706
 
 
707
    // private for compatibility, overridden by editor grid
 
708
    stopEditing : Ext.emptyFn,
 
709
 
 
710
    /**
 
711
     * Returns the grid's SelectionModel.
 
712
     * @return {SelectionModel} The selection model configured by the @link (#selModel} configuration option.
 
713
     * This will be a subclass of {@link Ext.grid.AbstractSelectionModel} which provides either cell or row
 
714
     * selectability. If no selection model was configured, this will return a {@link Ext.grid.RowSelectionModel RowSelectionModel}.
 
715
     */
 
716
    getSelectionModel : function(){
 
717
        if(!this.selModel){
 
718
            this.selModel = new Ext.grid.RowSelectionModel(
 
719
                    this.disableSelection ? {selectRow: Ext.emptyFn} : null);
 
720
        }
 
721
        return this.selModel;
 
722
    },
 
723
 
 
724
    /**
 
725
     * Returns the grid's data store.
 
726
     * @return {Ext.data.Store} The store
 
727
     */
 
728
    getStore : function(){
 
729
        return this.store;
 
730
    },
 
731
 
 
732
    /**
 
733
     * Returns the grid's ColumnModel.
 
734
     * @return {Ext.grid.ColumnModel} The column model
 
735
     */
 
736
    getColumnModel : function(){
 
737
        return this.colModel;
 
738
    },
 
739
 
 
740
    /**
 
741
     * Returns the grid's GridView object.
 
742
     * @return {Ext.grid.GridView} The grid view
 
743
     */
 
744
    getView : function(){
 
745
        if(!this.view){
 
746
            this.view = new Ext.grid.GridView(this.viewConfig);
 
747
        }
 
748
        return this.view;
 
749
    },
 
750
    /**
 
751
     * Called to get grid's drag proxy text, by default returns this.ddText.
 
752
     * @return {String} The text
 
753
     */
 
754
    getDragDropText : function(){
 
755
        var count = this.selModel.getCount();
 
756
        return String.format(this.ddText, count, count == 1 ? '' : 's');
 
757
    }
 
758
 
 
759
    /** 
 
760
     * @cfg {String/Number} activeItem 
 
761
     * @hide 
 
762
     */
 
763
    /** 
 
764
     * @cfg {Boolean} autoDestroy 
 
765
     * @hide 
 
766
     */
 
767
    /** 
 
768
     * @cfg {Object/String/Function} autoLoad 
 
769
     * @hide 
 
770
     */
 
771
    /** 
 
772
     * @cfg {Boolean} autoWidth 
 
773
     * @hide 
 
774
     */
 
775
    /** 
 
776
     * @cfg {Boolean/Number} bufferResize 
 
777
     * @hide 
 
778
     */
 
779
    /** 
 
780
     * @cfg {String} defaultType 
 
781
     * @hide 
 
782
     */
 
783
    /** 
 
784
     * @cfg {Object} defaults 
 
785
     * @hide 
 
786
     */
 
787
    /** 
 
788
     * @cfg {Boolean} hideBorders 
 
789
     * @hide 
 
790
     */
 
791
    /** 
 
792
     * @cfg {Mixed} items 
 
793
     * @hide 
 
794
     */
 
795
    /** 
 
796
     * @cfg {String} layout 
 
797
     * @hide 
 
798
     */
 
799
    /** 
 
800
     * @cfg {Object} layoutConfig 
 
801
     * @hide 
 
802
     */
 
803
    /** 
 
804
     * @cfg {Boolean} monitorResize 
 
805
     * @hide 
 
806
     */
 
807
    /** 
 
808
     * @property items 
 
809
     * @hide 
 
810
     */
 
811
    /** 
 
812
     * @method add 
 
813
     * @hide 
 
814
     */
 
815
    /** 
 
816
     * @method cascade 
 
817
     * @hide 
 
818
     */
 
819
    /** 
 
820
     * @method doLayout 
 
821
     * @hide 
 
822
     */
 
823
    /** 
 
824
     * @method find 
 
825
     * @hide 
 
826
     */
 
827
    /** 
 
828
     * @method findBy 
 
829
     * @hide 
 
830
     */
 
831
    /** 
 
832
     * @method findById 
 
833
     * @hide 
 
834
     */
 
835
    /** 
 
836
     * @method findByType 
 
837
     * @hide 
 
838
     */
 
839
    /** 
 
840
     * @method getComponent 
 
841
     * @hide 
 
842
     */
 
843
    /** 
 
844
     * @method getLayout 
 
845
     * @hide 
 
846
     */
 
847
    /** 
 
848
     * @method getUpdater 
 
849
     * @hide 
 
850
     */
 
851
    /** 
 
852
     * @method insert 
 
853
     * @hide 
 
854
     */
 
855
    /** 
 
856
     * @method load 
 
857
     * @hide 
 
858
     */
 
859
    /** 
 
860
     * @method remove 
 
861
     * @hide 
 
862
     */
 
863
    /** 
 
864
     * @event add 
 
865
     * @hide 
 
866
     */
 
867
    /** 
 
868
     * @event afterLayout 
 
869
     * @hide 
 
870
     */
 
871
    /** 
 
872
     * @event beforeadd 
 
873
     * @hide 
 
874
     */
 
875
    /** 
 
876
     * @event beforeremove 
 
877
     * @hide 
 
878
     */
 
879
    /** 
 
880
     * @event remove 
 
881
     * @hide 
 
882
     */
 
883
 
 
884
 
 
885
 
 
886
    /**
 
887
     * @cfg {String} allowDomMove  @hide
 
888
     */
 
889
    /**
 
890
     * @cfg {String} autoEl @hide
 
891
     */
 
892
    /**
 
893
     * @cfg {String} applyTo  @hide
 
894
     */
 
895
    /**
 
896
     * @cfg {String} autoScroll  @hide
 
897
     */
 
898
    /**
 
899
     * @cfg {String} bodyBorder  @hide
 
900
     */
 
901
    /**
 
902
     * @cfg {String} bodyStyle  @hide
 
903
     */
 
904
    /**
 
905
     * @cfg {String} contentEl  @hide
 
906
     */
 
907
    /**
 
908
     * @cfg {String} disabledClass  @hide
 
909
     */
 
910
    /**
 
911
     * @cfg {String} elements  @hide
 
912
     */
 
913
    /**
 
914
     * @cfg {String} html  @hide
 
915
     */
 
916
    /**
 
917
     * @property disabled
 
918
     * @hide
 
919
     */
 
920
    /**
 
921
     * @method applyToMarkup
 
922
     * @hide
 
923
     */
 
924
    /**
 
925
     * @method enable
 
926
     * @hide
 
927
     */
 
928
    /**
 
929
     * @method disable
 
930
     * @hide
 
931
     */
 
932
    /**
 
933
     * @method setDisabled
 
934
     * @hide
 
935
     */
 
936
});
 
937
Ext.reg('grid', Ext.grid.GridPanel);
 
 
b'\\ No newline at end of file'