Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / grid / feature / RowWrap.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @class Ext.grid.feature.RowWrap
17  * @extends Ext.grid.feature.Feature
18  * @private
19  */
20 Ext.define('Ext.grid.feature.RowWrap', {
21     extend: 'Ext.grid.feature.Feature',
22     alias: 'feature.rowwrap',
23
24     // turn off feature events.
25     hasFeatureEvent: false,
26     
27     mutateMetaRowTpl: function(metaRowTpl) {        
28         // Remove "x-grid-row" from the first row, note this could be wrong
29         // if some other feature unshifted things in front.
30         metaRowTpl[0] = metaRowTpl[0].replace(Ext.baseCSSPrefix + 'grid-row', '');
31         metaRowTpl[0] = metaRowTpl[0].replace("{[this.embedRowCls()]}", "");
32         // 2
33         metaRowTpl.unshift('<table class="' + Ext.baseCSSPrefix + 'grid-table ' + Ext.baseCSSPrefix + 'grid-table-resizer" style="width: {[this.embedFullWidth()]}px;">');
34         // 1
35         metaRowTpl.unshift('<tr class="' + Ext.baseCSSPrefix + 'grid-row {[this.embedRowCls()]}"><td colspan="{[this.embedColSpan()]}"><div class="' + Ext.baseCSSPrefix + 'grid-rowwrap-div">');
36         
37         // 3
38         metaRowTpl.push('</table>');
39         // 4
40         metaRowTpl.push('</div></td></tr>');
41     },
42     
43     embedColSpan: function() {
44         return '{colspan}';
45     },
46     
47     embedFullWidth: function() {
48         return '{fullWidth}';
49     },
50     
51     getAdditionalData: function(data, idx, record, orig) {
52         var headerCt = this.view.headerCt,
53             colspan  = headerCt.getColumnCount(),
54             fullWidth = headerCt.getFullWidth(),
55             items    = headerCt.query('gridcolumn'),
56             itemsLn  = items.length,
57             i = 0,
58             o = {
59                 colspan: colspan,
60                 fullWidth: fullWidth
61             },
62             id,
63             tdClsKey,
64             colResizerCls;
65
66         for (; i < itemsLn; i++) {
67             id = items[i].id;
68             tdClsKey = id + '-tdCls';
69             colResizerCls = Ext.baseCSSPrefix + 'grid-col-resizer-'+id;
70             // give the inner td's the resizer class
71             // while maintaining anything a user may have injected via a custom
72             // renderer
73             o[tdClsKey] = colResizerCls + " " + (orig[tdClsKey] ? orig[tdClsKey] : '');
74             // TODO: Unhackify the initial rendering width's
75             o[id+'-tdAttr'] = " style=\"width: " + (items[i].hidden ? 0 : items[i].getDesiredWidth()) + "px;\" "/* + (i === 0 ? " rowspan=\"2\"" : "")*/;
76             if (orig[id+'-tdAttr']) {
77                 o[id+'-tdAttr'] += orig[id+'-tdAttr'];
78             }
79             
80         }
81
82         return o;
83     },
84     
85     getMetaRowTplFragments: function() {
86         return {
87             embedFullWidth: this.embedFullWidth,
88             embedColSpan: this.embedColSpan
89         };
90     }
91     
92 });