4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-grid-RowNumberer'>/**
19 </span> * This is a utility class that can be passed into a {@link Ext.grid.column.Column} as a column config that provides
20 * an automatic row numbering column.
25 * {xtype: 'rownumberer'},
26 * {text: "Company", flex: 1, sortable: true, dataIndex: 'company'},
27 * {text: "Price", width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
28 * {text: "Change", width: 120, sortable: true, dataIndex: 'change'},
29 * {text: "% Change", width: 120, sortable: true, dataIndex: 'pctChange'},
30 * {text: "Last Updated", width: 120, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
34 Ext.define('Ext.grid.RowNumberer', {
35 extend: 'Ext.grid.column.Column',
36 alias: 'widget.rownumberer',
38 <span id='Ext-grid-RowNumberer-cfg-text'> /**
39 </span> * @cfg {String} text
40 * Any valid text or HTML fragment to display in the header cell for the row number column.
42 text: "&#160",
44 <span id='Ext-grid-RowNumberer-cfg-width'> /**
45 </span> * @cfg {Number} width
46 * The default width in pixels of the row number column.
50 <span id='Ext-grid-RowNumberer-cfg-sortable'> /**
51 </span> * @cfg {Boolean} sortable
52 * True if the row number column is sortable.
59 constructor : function(config){
60 this.callParent(arguments);
62 this.renderer = Ext.Function.bind(this.renderer, this);
71 cls: Ext.baseCSSPrefix + 'row-numberer',
75 renderer: function(value, metaData, record, rowIdx, colIdx, store) {
77 metaData.cellAttr = 'rowspan="'+this.rowspan+'"';
80 metaData.tdCls = Ext.baseCSSPrefix + 'grid-cell-special';
81 return store.indexOfTotal(record) + 1;