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', {
32 * Drag and drop functionality can be achieved in the grid by attaching a {@link Ext.grid.plugin.DragDrop} plugin
33 * when creating the view.
35 * Ext.create('Ext.grid.Panel', {
39 * ddGroup: 'people-group',
40 * ptype: 'gridviewdragdrop',
46 Ext.define('Ext.grid.View', {
47 extend: 'Ext.view.Table',
48 alias: 'widget.gridview',
51 * @cfg {Boolean} stripeRows <tt>true</tt> to stripe the rows. Default is <tt>true</tt>.
52 * <p>This causes the CSS class <tt><b>x-grid-row-alt</b></tt> to be added to alternate rows of
53 * the grid. A default CSS rule is provided which sets a background color, but you can override this
54 * with a rule which either overrides the <b>background-color</b> style using the '!important'
55 * modifier, or which uses a CSS selector of higher specificity.</p>
59 invalidateScrollerOnRefresh: true,
62 * Scroll the GridView to the top by scrolling the scroller.
65 scrollToTop : function(){
67 var section = this.ownerCt,
68 verticalScroller = section.verticalScroller;
70 if (verticalScroller) {
71 verticalScroller.scrollToTop();
76 // after adding a row stripe rows from then on
77 onAdd: function(ds, records, index) {
78 this.callParent(arguments);
79 this.doStripeRows(index);
82 // after removing a row stripe rows from then on
83 onRemove: function(ds, records, index) {
84 this.callParent(arguments);
85 this.doStripeRows(index);
88 onUpdate: function(ds, record, operation) {
89 var index = ds.indexOf(record);
90 this.callParent(arguments);
91 this.doStripeRows(index, index);
95 * Stripe rows from a particular row index
96 * @param {Number} startRow
97 * @param {Number} endRow (Optional) argument specifying the last row to process. By default process up to the last row.
100 doStripeRows: function(startRow, endRow) {
101 // ensure stripeRows configuration is turned on
102 if (this.stripeRows) {
103 var rows = this.getNodes(startRow, endRow),
104 rowsLn = rows.length,
108 for (; i < rowsLn; i++) {
110 // Remove prior applied row classes.
111 row.className = row.className.replace(this.rowClsRe, ' ');
113 // Every odd row will get an additional cls
114 if (startRow % 2 === 0) {
115 row.className += (' ' + this.altRowCls);
121 refresh: function(firstPass) {
122 this.callParent(arguments);
123 this.doStripeRows(0);
124 // TODO: Remove gridpanel dependency
125 var g = this.up('gridpanel');
126 if (g && this.invalidateScrollerOnRefresh) {
127 g.invalidateScroller();