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