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 * This is a utility class that can be passed into a {@link Ext.grid.column.Column} as a column config that provides
17 * an automatic row numbering column.
22 * {xtype: 'rownumberer'},
23 * {text: "Company", flex: 1, sortable: true, dataIndex: 'company'},
24 * {text: "Price", width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
25 * {text: "Change", width: 120, sortable: true, dataIndex: 'change'},
26 * {text: "% Change", width: 120, sortable: true, dataIndex: 'pctChange'},
27 * {text: "Last Updated", width: 120, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
31 Ext.define('Ext.grid.RowNumberer', {
32 extend: 'Ext.grid.column.Column',
33 alias: 'widget.rownumberer',
37 * Any valid text or HTML fragment to display in the header cell for the row number column.
43 * The default width in pixels of the row number column.
48 * @cfg {Boolean} sortable
49 * True if the row number column is sortable.
56 constructor : function(config){
57 this.callParent(arguments);
59 this.renderer = Ext.Function.bind(this.renderer, this);
68 cls: Ext.baseCSSPrefix + 'row-numberer',
72 renderer: function(value, metaData, record, rowIdx, colIdx, store) {
74 metaData.cellAttr = 'rowspan="'+this.rowspan+'"';
77 metaData.tdCls = Ext.baseCSSPrefix + 'grid-cell-special';
78 return store.indexOfTotal(record) + 1;