X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/grid/RowNumberer.js
diff --git a/src/grid/RowNumberer.js b/src/grid/RowNumberer.js
new file mode 100644
index 00000000..7912428b
--- /dev/null
+++ b/src/grid/RowNumberer.js
@@ -0,0 +1,65 @@
+/**
+ * @class Ext.grid.RowNumberer
+ * @extends Ext.grid.column.Column
+ * This is a utility class that can be passed into a {@link Ext.grid.column.Column} as a column config that provides
+ * an automatic row numbering column.
+ *
Usage:
+columns: [
+ Ext.create('Ext.grid.RowNumberer'),
+ {text: "Company", flex: 1, sortable: true, dataIndex: 'company'},
+ {text: "Price", width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
+ {text: "Change", width: 120, sortable: true, dataIndex: 'change'},
+ {text: "% Change", width: 120, sortable: true, dataIndex: 'pctChange'},
+ {text: "Last Updated", width: 120, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
+]
+ *
+ * @constructor
+ * @param {Object} config The configuration options
+ */
+Ext.define('Ext.grid.RowNumberer', {
+ extend: 'Ext.grid.column.Column',
+ alias: 'widget.rownumberer',
+ /**
+ * @cfg {String} text Any valid text or HTML fragment to display in the header cell for the row
+ * number column (defaults to ' ').
+ */
+ text: " ",
+
+ /**
+ * @cfg {Number} width The default width in pixels of the row number column (defaults to 23).
+ */
+ width: 23,
+
+ /**
+ * @cfg {Boolean} sortable True if the row number column is sortable (defaults to false).
+ * @hide
+ */
+ sortable: false,
+
+ align: 'right',
+
+ constructor : function(config){
+ this.callParent(arguments);
+ if (this.rowspan) {
+ this.renderer = Ext.Function.bind(this.renderer, this);
+ }
+ },
+
+ // private
+ fixed: true,
+ hideable: false,
+ menuDisabled: true,
+ dataIndex: '',
+ cls: Ext.baseCSSPrefix + 'row-numberer',
+ rowspan: undefined,
+
+ // private
+ renderer: function(value, metaData, record, rowIdx, colIdx, store) {
+ if (this.rowspan){
+ metaData.cellAttr = 'rowspan="'+this.rowspan+'"';
+ }
+
+ metaData.tdCls = Ext.baseCSSPrefix + 'grid-cell-special';
+ return store.indexOfTotal(record) + 1;
+ }
+});