Feature.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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-feature-Feature'>/**
  19. </span> * A feature is a type of plugin that is specific to the {@link Ext.grid.Panel}. It provides several
  20. * hooks that allows the developer to inject additional functionality at certain points throughout the
  21. * grid creation cycle. This class provides the base template methods that are available to the developer,
  22. * it should be extended.
  23. *
  24. * There are several built in features that extend this class, for example:
  25. *
  26. * - {@link Ext.grid.feature.Grouping} - Shows grid rows in groups as specified by the {@link Ext.data.Store}
  27. * - {@link Ext.grid.feature.RowBody} - Adds a body section for each grid row that can contain markup.
  28. * - {@link Ext.grid.feature.Summary} - Adds a summary row at the bottom of the grid with aggregate totals for a column.
  29. *
  30. * ## Using Features
  31. * A feature is added to the grid by specifying it an array of features in the configuration:
  32. *
  33. * var groupingFeature = Ext.create('Ext.grid.feature.Grouping');
  34. * Ext.create('Ext.grid.Panel', {
  35. * // other options
  36. * features: [groupingFeature]
  37. * });
  38. *
  39. * @abstract
  40. */
  41. Ext.define('Ext.grid.feature.Feature', {
  42. extend: 'Ext.util.Observable',
  43. alias: 'feature.feature',
  44. /*
  45. * @property {Boolean} isFeature
  46. * `true` in this class to identify an object as an instantiated Feature, or subclass thereof.
  47. */
  48. isFeature: true,
  49. <span id='Ext-grid-feature-Feature-property-disabled'> /**
  50. </span> * True when feature is disabled.
  51. */
  52. disabled: false,
  53. <span id='Ext-grid-feature-Feature-property-hasFeatureEvent'> /**
  54. </span> * @property {Boolean}
  55. * Most features will expose additional events, some may not and will
  56. * need to change this to false.
  57. */
  58. hasFeatureEvent: true,
  59. <span id='Ext-grid-feature-Feature-property-eventPrefix'> /**
  60. </span> * @property {String}
  61. * Prefix to use when firing events on the view.
  62. * For example a prefix of group would expose &quot;groupclick&quot;, &quot;groupcontextmenu&quot;, &quot;groupdblclick&quot;.
  63. */
  64. eventPrefix: null,
  65. <span id='Ext-grid-feature-Feature-property-eventSelector'> /**
  66. </span> * @property {String}
  67. * Selector used to determine when to fire the event with the eventPrefix.
  68. */
  69. eventSelector: null,
  70. <span id='Ext-grid-feature-Feature-property-view'> /**
  71. </span> * @property {Ext.view.Table}
  72. * Reference to the TableView.
  73. */
  74. view: null,
  75. <span id='Ext-grid-feature-Feature-property-grid'> /**
  76. </span> * @property {Ext.grid.Panel}
  77. * Reference to the grid panel
  78. */
  79. grid: null,
  80. <span id='Ext-grid-feature-Feature-property-collectData'> /**
  81. </span> * Most features will not modify the data returned to the view.
  82. * This is limited to one feature that manipulates the data per grid view.
  83. */
  84. collectData: false,
  85. constructor: function(config) {
  86. this.initialConfig = config;
  87. this.callParent(arguments);
  88. },
  89. clone: function() {
  90. return new this.self(this.initialConfig);
  91. },
  92. init: Ext.emptyFn,
  93. getFeatureTpl: function() {
  94. return '';
  95. },
  96. <span id='Ext-grid-feature-Feature-method-getFireEventArgs'> /**
  97. </span> * Abstract method to be overriden when a feature should add additional
  98. * arguments to its event signature. By default the event will fire:
  99. *
  100. * - view - The underlying Ext.view.Table
  101. * - featureTarget - The matched element by the defined {@link #eventSelector}
  102. *
  103. * The method must also return the eventName as the first index of the array
  104. * to be passed to fireEvent.
  105. * @template
  106. */
  107. getFireEventArgs: function(eventName, view, featureTarget, e) {
  108. return [eventName, view, featureTarget, e];
  109. },
  110. <span id='Ext-grid-feature-Feature-method-attachEvents'> /**
  111. </span> * Approriate place to attach events to the view, selectionmodel, headerCt, etc
  112. * @template
  113. */
  114. attachEvents: function() {
  115. },
  116. getFragmentTpl: Ext.emptyFn,
  117. <span id='Ext-grid-feature-Feature-method-mutateMetaRowTpl'> /**
  118. </span> * Allows a feature to mutate the metaRowTpl.
  119. * The array received as a single argument can be manipulated to add things
  120. * on the end/begining of a particular row.
  121. * @param {Array} metaRowTplArray A String array to be used constructing an {@link Ext.XTemplate XTemplate}
  122. * to render the rows. This Array may be changed to provide extra DOM structure.
  123. * @template
  124. */
  125. mutateMetaRowTpl: Ext.emptyFn,
  126. <span id='Ext-grid-feature-Feature-method-getMetaRowTplFragments'> /**
  127. </span> * Allows a feature to inject member methods into the metaRowTpl. This is
  128. * important for embedding functionality which will become part of the proper
  129. * row tpl.
  130. * @template
  131. */
  132. getMetaRowTplFragments: function() {
  133. return {};
  134. },
  135. getTableFragments: function() {
  136. return {};
  137. },
  138. <span id='Ext-grid-feature-Feature-method-getAdditionalData'> /**
  139. </span> * Provide additional data to the prepareData call within the grid view.
  140. * @param {Object} data The data for this particular record.
  141. * @param {Number} idx The row index for this record.
  142. * @param {Ext.data.Model} record The record instance
  143. * @param {Object} orig The original result from the prepareData call to massage.
  144. * @template
  145. */
  146. getAdditionalData: function(data, idx, record, orig) {
  147. return {};
  148. },
  149. <span id='Ext-grid-feature-Feature-method-enable'> /**
  150. </span> * Enables the feature.
  151. */
  152. enable: function() {
  153. this.disabled = false;
  154. },
  155. <span id='Ext-grid-feature-Feature-method-disable'> /**
  156. </span> * Disables the feature.
  157. */
  158. disable: function() {
  159. this.disabled = true;
  160. }
  161. });</pre>
  162. </body>
  163. </html>