Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / grid / feature / RowWrap.js
1 /**
2  * @class Ext.grid.feature.RowWrap
3  * @extends Ext.grid.feature.Feature
4  * @private
5  */
6 Ext.define('Ext.grid.feature.RowWrap', {
7     extend: 'Ext.grid.feature.Feature',
8     alias: 'feature.rowwrap',
9
10     // turn off feature events.
11     hasFeatureEvent: false,
12     
13     mutateMetaRowTpl: function(metaRowTpl) {        
14         // Remove "x-grid-row" from the first row, note this could be wrong
15         // if some other feature unshifted things in front.
16         metaRowTpl[0] = metaRowTpl[0].replace(Ext.baseCSSPrefix + 'grid-row', '');
17         metaRowTpl[0] = metaRowTpl[0].replace("{[this.embedRowCls()]}", "");
18         // 2
19         metaRowTpl.unshift('<table class="' + Ext.baseCSSPrefix + 'grid-table ' + Ext.baseCSSPrefix + 'grid-table-resizer" style="width: {[this.embedFullWidth()]}px;">');
20         // 1
21         metaRowTpl.unshift('<tr class="' + Ext.baseCSSPrefix + 'grid-row {[this.embedRowCls()]}"><td colspan="{[this.embedColSpan()]}"><div class="' + Ext.baseCSSPrefix + 'grid-rowwrap-div">');
22         
23         // 3
24         metaRowTpl.push('</table>');
25         // 4
26         metaRowTpl.push('</div></td></tr>');
27     },
28     
29     embedColSpan: function() {
30         return '{colspan}';
31     },
32     
33     embedFullWidth: function() {
34         return '{fullWidth}';
35     },
36     
37     getAdditionalData: function(data, idx, record, orig) {
38         var headerCt = this.view.headerCt,
39             colspan  = headerCt.getColumnCount(),
40             fullWidth = headerCt.getFullWidth(),
41             items    = headerCt.query('gridcolumn'),
42             itemsLn  = items.length,
43             i = 0,
44             o = {
45                 colspan: colspan,
46                 fullWidth: fullWidth
47             },
48             id,
49             tdClsKey,
50             colResizerCls;
51
52         for (; i < itemsLn; i++) {
53             id = items[i].id;
54             tdClsKey = id + '-tdCls';
55             colResizerCls = Ext.baseCSSPrefix + 'grid-col-resizer-'+id;
56             // give the inner td's the resizer class
57             // while maintaining anything a user may have injected via a custom
58             // renderer
59             o[tdClsKey] = colResizerCls + " " + (orig[tdClsKey] ? orig[tdClsKey] : '');
60             // TODO: Unhackify the initial rendering width's
61             o[id+'-tdAttr'] = " style=\"width: " + (items[i].hidden ? 0 : items[i].getDesiredWidth()) + "px;\" "/* + (i === 0 ? " rowspan=\"2\"" : "")*/;
62             if (orig[id+'-tdAttr']) {
63                 o[id+'-tdAttr'] += orig[id+'-tdAttr'];
64             }
65             
66         }
67
68         return o;
69     },
70     
71     getMetaRowTplFragments: function() {
72         return {
73             embedFullWidth: this.embedFullWidth,
74             embedColSpan: this.embedColSpan
75         };
76     }
77     
78 });