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.

84 lines
2.6 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.ns('Ext.ux.grid');
  16. /**
  17. * @class Ext.ux.grid.CheckColumn
  18. * @extends Ext.grid.Column
  19. * <p>A Column subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.</p>
  20. * <p><b>Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel.</b></p>
  21. * <p>Example usage:</p>
  22. * <pre><code>
  23. var cm = new Ext.grid.ColumnModel([{
  24. header: 'Foo',
  25. ...
  26. },{
  27. xtype: 'checkcolumn',
  28. header: 'Indoor?',
  29. dataIndex: 'indoor',
  30. width: 55
  31. }
  32. ]);
  33. // create the grid
  34. var grid = new Ext.grid.EditorGridPanel({
  35. ...
  36. colModel: cm,
  37. ...
  38. });
  39. * </code></pre>
  40. * In addition to toggling a Boolean value within the record data, this
  41. * class toggles a css class between <tt>'x-grid3-check-col'</tt> and
  42. * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
  43. * a column.
  44. */
  45. Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
  46. /**
  47. * @private
  48. * Process and refire events routed from the GridView's processEvent method.
  49. */
  50. processEvent : function(name, e, grid, rowIndex, colIndex){
  51. if (name == 'mousedown') {
  52. var record = grid.store.getAt(rowIndex);
  53. record.set(this.dataIndex, !record.data[this.dataIndex]);
  54. return false; // Cancel row selection.
  55. } else {
  56. return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
  57. }
  58. },
  59. renderer : function(v, p, record){
  60. p.css += ' x-grid3-check-col-td';
  61. return String.format('<div class="x-grid3-check-col{0}">&#160;</div>', v ? '-on' : '');
  62. },
  63. // Deprecate use as a plugin. Remove in 4.0
  64. init: Ext.emptyFn
  65. });
  66. // register ptype. Deprecate. Remove in 4.0
  67. Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);
  68. // backwards compat. Remove in 4.0
  69. Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;
  70. // register Column xtype
  71. Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;