94f949d03cc7f10c824ea1fa08115fc738861157.svn-base 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. /**
  7. * @class Ext.grid.RowNumberer This is a utility class that can be passed into a
  8. * {@link Ext.grid.ColumnModel} as a column config that provides an
  9. * automatic row numbering column. <br>
  10. * Usage:<br>
  11. *
  12. * <pre><code>
  13. * // This is a typical column config with the first column providing row numbers
  14. * var colModel = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
  15. * header : &quot;Name&quot;,
  16. * width : 80,
  17. * sortable : true
  18. * }, {
  19. * header : &quot;Code&quot;,
  20. * width : 50,
  21. * sortable : true
  22. * }, {
  23. * header : &quot;Description&quot;,
  24. * width : 200,
  25. * sortable : true
  26. * }]);
  27. * </code></pre>
  28. *
  29. * @constructor
  30. * @param {Object}
  31. * config The configuration options
  32. */
  33. Ext.grid.RowNumberer = function(config) {
  34. Ext.apply(this, config);
  35. if (this.rowspan) {
  36. this.renderer = this.renderer.createDelegate(this);
  37. }
  38. };
  39. Ext.grid.RowNumberer.prototype = {
  40. /**
  41. * @cfg {String} header Any valid text or HTML fragment to display in the
  42. * header cell for the row number column (defaults to '').
  43. */
  44. header : "",
  45. /**
  46. * @cfg {Number} width The default width in pixels of the row number column
  47. * (defaults to 23).
  48. */
  49. width : 23,
  50. /**
  51. * @cfg {Boolean} sortable True if the row number column is sortable
  52. * (defaults to false).
  53. */
  54. sortable : false,
  55. // private
  56. fixed : true,
  57. dataIndex : '',
  58. id : 'numberer',
  59. rowspan : undefined,
  60. // private
  61. renderer : function(v, p, record, rowIndex) {
  62. if (this.rowspan) {
  63. p.cellAttr = 'rowspan="' + this.rowspan + '"';
  64. }
  65. return rowIndex + 1;
  66. }
  67. };