Boolean2.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-grid-column-Boolean'>/**
  19. </span> * A Column definition class which renders boolean data fields. See the {@link Ext.grid.column.Column#xtype xtype}
  20. * config option of {@link Ext.grid.column.Column} for more details.
  21. *
  22. * @example
  23. * Ext.create('Ext.data.Store', {
  24. * storeId:'sampleStore',
  25. * fields:[
  26. * {name: 'framework', type: 'string'},
  27. * {name: 'rocks', type: 'boolean'}
  28. * ],
  29. * data:{'items':[
  30. * { 'framework': &quot;Ext JS 4&quot;, 'rocks': true },
  31. * { 'framework': &quot;Sencha Touch&quot;, 'rocks': true },
  32. * { 'framework': &quot;Ext GWT&quot;, 'rocks': true },
  33. * { 'framework': &quot;Other Guys&quot;, 'rocks': false }
  34. * ]},
  35. * proxy: {
  36. * type: 'memory',
  37. * reader: {
  38. * type: 'json',
  39. * root: 'items'
  40. * }
  41. * }
  42. * });
  43. *
  44. * Ext.create('Ext.grid.Panel', {
  45. * title: 'Boolean Column Demo',
  46. * store: Ext.data.StoreManager.lookup('sampleStore'),
  47. * columns: [
  48. * { text: 'Framework', dataIndex: 'framework', flex: 1 },
  49. * {
  50. * xtype: 'booleancolumn',
  51. * text: 'Rocks',
  52. * trueText: 'Yes',
  53. * falseText: 'No',
  54. * dataIndex: 'rocks'
  55. * }
  56. * ],
  57. * height: 200,
  58. * width: 400,
  59. * renderTo: Ext.getBody()
  60. * });
  61. */
  62. Ext.define('Ext.grid.column.Boolean', {
  63. extend: 'Ext.grid.column.Column',
  64. alias: ['widget.booleancolumn'],
  65. alternateClassName: 'Ext.grid.BooleanColumn',
  66. //&lt;locale&gt;
  67. <span id='Ext-grid-column-Boolean-cfg-trueText'> /**
  68. </span> * @cfg {String} trueText
  69. * The string returned by the renderer when the column value is not falsey.
  70. */
  71. trueText: 'true',
  72. //&lt;/locale&gt;
  73. //&lt;locale&gt;
  74. <span id='Ext-grid-column-Boolean-cfg-falseText'> /**
  75. </span> * @cfg {String} falseText
  76. * The string returned by the renderer when the column value is falsey (but not undefined).
  77. */
  78. falseText: 'false',
  79. //&lt;/locale&gt;
  80. <span id='Ext-grid-column-Boolean-cfg-undefinedText'> /**
  81. </span> * @cfg {String} undefinedText
  82. * The string returned by the renderer when the column value is undefined.
  83. */
  84. undefinedText: '&amp;#160;',
  85. <span id='Ext-grid-column-Boolean-cfg-renderer'> /**
  86. </span> * @cfg renderer
  87. * @hide
  88. */
  89. <span id='Ext-grid-column-Boolean-cfg-scope'> /**
  90. </span> * @cfg scope
  91. * @hide
  92. */
  93. defaultRenderer: function(value){
  94. if (value === undefined) {
  95. return this.undefinedText;
  96. }
  97. if (!value || value === 'false') {
  98. return this.falseText;
  99. }
  100. return this.trueText;
  101. }
  102. });</pre>
  103. </body>
  104. </html>