3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.grid.View
17 * @extends Ext.view.Table
19 The grid View class provides extra {@link Ext.grid.Panel} specific functionality to the
20 {@link Ext.view.Table}. In general, this class is not instanced directly, instead a viewConfig
21 option is passed to the grid:
23 Ext.create('Ext.grid.Panel', {
31 Drag and drop functionality can be achieved in the grid by attaching a {@link Ext.grid.plugin.DragDrop} plugin
32 when creating the view.
34 Ext.create('Ext.grid.Panel', {
38 ddGroup: 'people-group',
39 ptype: 'gridviewdragdrop',
47 Ext.define('Ext.grid.View', {
48 extend: 'Ext.view.Table',
49 alias: 'widget.gridview',
52 * @cfg {Boolean} stripeRows <tt>true</tt> to stripe the rows. Default is <tt>false</tt>.
53 * <p>This causes the CSS class <tt><b>x-grid-row-alt</b></tt> to be added to alternate rows of
54 * the grid. A default CSS rule is provided which sets a background color, but you can override this
55 * with a rule which either overrides the <b>background-color</b> style using the '!important'
56 * modifier, or which uses a CSS selector of higher specificity.</p>
60 invalidateScrollerOnRefresh: true,
63 * Scroll the GridView to the top by scrolling the scroller.
66 scrollToTop : function(){
68 var section = this.ownerCt,
69 verticalScroller = section.verticalScroller;
71 if (verticalScroller) {
72 verticalScroller.scrollToTop();
77 // after adding a row stripe rows from then on
78 onAdd: function(ds, records, index) {
79 this.callParent(arguments);
80 this.doStripeRows(index);
83 // after removing a row stripe rows from then on
84 onRemove: function(ds, records, index) {
85 this.callParent(arguments);
86 this.doStripeRows(index);
89 onUpdate: function(ds, record, operation) {
90 var index = ds.indexOf(record);
91 this.callParent(arguments);
92 this.doStripeRows(index, index);
96 * Stripe rows from a particular row index
97 * @param {Number} startRow
98 * @param {Number} endRow Optional argument specifying the last row to process. By default process up to the last row.
101 doStripeRows: function(startRow, endRow) {
102 // ensure stripeRows configuration is turned on
103 if (this.stripeRows) {
104 var rows = this.getNodes(startRow, endRow),
105 rowsLn = rows.length,
109 for (; i < rowsLn; i++) {
111 // Remove prior applied row classes.
112 row.className = row.className.replace(this.rowClsRe, ' ');
114 // Every odd row will get an additional cls
115 if (startRow % 2 === 0) {
116 row.className += (' ' + this.altRowCls);
122 refresh: function(firstPass) {
123 this.callParent(arguments);
124 this.doStripeRows(0);
125 // TODO: Remove gridpanel dependency
126 var g = this.up('gridpanel');
127 if (g && this.invalidateScrollerOnRefresh) {
128 g.invalidateScroller();