TfColumn.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * 自定义grid.column
  3. * tf即true/false,显示为是和否,其实际值对应T和F
  4. */
  5. Ext.define('erp.view.core.grid.TfColumn', {
  6. extend : 'Ext.grid.column.Column',
  7. alias : [ 'widget.tfcolumn' ],
  8. trueText : $I18N.common.form.yes,
  9. falseText : $I18N.common.form.no,
  10. constructor : function(cfg) {
  11. this.callParent(arguments);
  12. this.editor = {
  13. xtype : 'combo',
  14. store : Ext.create('Ext.data.Store', {
  15. fields : [ 'display', 'value' ],
  16. data : [ {
  17. "display" : $I18N.common.form.yes,
  18. "value" : 'T'
  19. }, {
  20. "display" : $I18N.common.form.no,
  21. "value" : 'F'
  22. } ]
  23. }),
  24. editable: false,
  25. displayField : 'display',
  26. valueField : 'value',
  27. queryMode : 'local',
  28. value : 'F',
  29. hideTrigger : false,
  30. listeners: {
  31. scope: this,
  32. 'change': function(c){
  33. if(c.rawValue != this.trueText && c.rawValue != this.falseText){
  34. //实现grid单元格编辑模式下,不让用户编辑combo
  35. if(contains(c.rawValue, this.falseText, true)){
  36. c.setValue(this.falseText);
  37. } else if(contains(c.rawValue, this.trueText, true)){
  38. c.setValue(this.trueText);
  39. } else {
  40. c.setValue(this.falseText);
  41. }
  42. }
  43. }
  44. }
  45. };
  46. var trueText = this.trueText, falseText = this.falseText;
  47. this.renderer = function(value) {
  48. if (value === undefined) {
  49. return falseText;
  50. }
  51. if (!value || value == 'F') {
  52. return falseText;
  53. }
  54. return trueText;
  55. };
  56. }
  57. });
  58. Ext.data.Types.TF = {
  59. convert : function(v, data) {
  60. if(!v || v == '')
  61. v = 'F';
  62. return v;
  63. },
  64. sortType : function(v) {
  65. return v.Latitude;
  66. },
  67. type : 'tf'
  68. };