You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.1 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.ns('Ext.ux.grid');
  8. /**
  9. * @class Ext.ux.grid.CheckColumn
  10. * @extends Ext.grid.Column
  11. * <p>A Column subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.</p>
  12. * <p><b>Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel.</b></p>
  13. * <p>Example usage:</p>
  14. * <pre><code>
  15. var cm = new Ext.grid.ColumnModel([{
  16. header: 'Foo',
  17. ...
  18. },{
  19. xtype: 'checkcolumn',
  20. header: 'Indoor?',
  21. dataIndex: 'indoor',
  22. width: 55
  23. }
  24. ]);
  25. // create the grid
  26. var grid = new Ext.grid.EditorGridPanel({
  27. ...
  28. colModel: cm,
  29. ...
  30. });
  31. * </code></pre>
  32. * In addition to toggling a Boolean value within the record data, this
  33. * class toggles a css class between <tt>'x-grid3-check-col'</tt> and
  34. * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
  35. * a column.
  36. */
  37. Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
  38. /**
  39. * @private
  40. * Process and refire events routed from the GridView's processEvent method.
  41. */
  42. processEvent : function(name, e, grid, rowIndex, colIndex){
  43. if (name == 'mousedown') {
  44. var record = grid.store.getAt(rowIndex);
  45. record.set(this.dataIndex, !record.data[this.dataIndex]);
  46. return false; // Cancel row selection.
  47. } else {
  48. return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
  49. }
  50. },
  51. renderer : function(v, p, record){
  52. p.css += ' x-grid3-check-col-td';
  53. return String.format('<div class="x-grid3-check-col{0}">&#160;</div>', v ? '-on' : '');
  54. },
  55. // Deprecate use as a plugin. Remove in 4.0
  56. init: Ext.emptyFn
  57. });
  58. // register ptype. Deprecate. Remove in 4.0
  59. Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);
  60. // backwards compat. Remove in 4.0
  61. Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;
  62. // register Column xtype
  63. Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;