Upgrade to ExtJS 3.1.0 - Released 12/16/2009
[extjs.git] / docs / source / GroupingView.html
1 <html>\r
2 <head>\r
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
4   <title>The source code</title>\r
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
7 </head>\r
8 <body  onload="prettyPrint();">\r
9     <pre class="prettyprint lang-js"><div id="cls-Ext.grid.GroupingView"></div>/**\r
10  * @class Ext.grid.GroupingView\r
11  * @extends Ext.grid.GridView\r
12  * Adds the ability for single level grouping to the grid. A {@link Ext.data.GroupingStore GroupingStore}\r
13  * must be used to enable grouping.  Some grouping characteristics may also be configured at the\r
14  * {@link Ext.grid.Column Column level}<div class="mdetail-params"><ul>\r
15  * <li><code>{@link Ext.grid.Column#emptyGroupText emptyGroupText}</li>\r
16  * <li><code>{@link Ext.grid.Column#groupable groupable}</li>\r
17  * <li><code>{@link Ext.grid.Column#groupName groupName}</li>\r
18  * <li><code>{@link Ext.grid.Column#groupRender groupRender}</li>\r
19  * </ul></div>\r
20  * <p>Sample usage:</p>\r
21  * <pre><code>\r
22 var grid = new Ext.grid.GridPanel({\r
23     // A groupingStore is required for a GroupingView\r
24     store: new {@link Ext.data.GroupingStore}({\r
25         autoDestroy: true,\r
26         reader: reader,\r
27         data: xg.dummyData,\r
28         sortInfo: {field: 'company', direction: 'ASC'},\r
29         {@link Ext.data.GroupingStore#groupOnSort groupOnSort}: true,\r
30         {@link Ext.data.GroupingStore#remoteGroup remoteGroup}: true,\r
31         {@link Ext.data.GroupingStore#groupField groupField}: 'industry'\r
32     }),\r
33     colModel: new {@link Ext.grid.ColumnModel}({\r
34         columns:[\r
35             {id:'company',header: 'Company', width: 60, dataIndex: 'company'},\r
36             // {@link Ext.grid.Column#groupable groupable}, {@link Ext.grid.Column#groupName groupName}, {@link Ext.grid.Column#groupRender groupRender} are also configurable at column level\r
37             {header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price', {@link Ext.grid.Column#groupable groupable}: false},\r
38             {header: 'Change', dataIndex: 'change', renderer: Ext.util.Format.usMoney},\r
39             {header: 'Industry', dataIndex: 'industry'},\r
40             {header: 'Last Updated', renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}\r
41         ],\r
42         defaults: {\r
43             sortable: true,\r
44             menuDisabled: false,\r
45             width: 20\r
46         }\r
47     }),\r
48 \r
49     view: new Ext.grid.GroupingView({\r
50         {@link Ext.grid.GridView#forceFit forceFit}: true,\r
51         // custom grouping text template to display the number of items per group\r
52         {@link #groupTextTpl}: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'\r
53     }),\r
54 \r
55     frame:true,\r
56     width: 700,\r
57     height: 450,\r
58     collapsible: true,\r
59     animCollapse: false,\r
60     title: 'Grouping Example',\r
61     iconCls: 'icon-grid',\r
62     renderTo: document.body\r
63 });\r
64  * </code></pre>\r
65  * @constructor\r
66  * @param {Object} config\r
67  */\r
68 Ext.grid.GroupingView = Ext.extend(Ext.grid.GridView, {\r
69 \r
70     <div id="cfg-Ext.grid.GroupingView-groupByText"></div>/**\r
71      * @cfg {String} groupByText Text displayed in the grid header menu for grouping by a column\r
72      * (defaults to 'Group By This Field').\r
73      */\r
74     groupByText : 'Group By This Field',\r
75     <div id="cfg-Ext.grid.GroupingView-showGroupsText"></div>/**\r
76      * @cfg {String} showGroupsText Text displayed in the grid header for enabling/disabling grouping\r
77      * (defaults to 'Show in Groups').\r
78      */\r
79     showGroupsText : 'Show in Groups',\r
80     <div id="cfg-Ext.grid.GroupingView-hideGroupedColumn"></div>/**\r
81      * @cfg {Boolean} hideGroupedColumn <tt>true</tt> to hide the column that is currently grouped (defaults to <tt>false</tt>)\r
82      */\r
83     hideGroupedColumn : false,\r
84     <div id="cfg-Ext.grid.GroupingView-showGroupName"></div>/**\r
85      * @cfg {Boolean} showGroupName If <tt>true</tt> will display a prefix plus a ': ' before the group field value\r
86      * in the group header line.  The prefix will consist of the <tt><b>{@link Ext.grid.Column#groupName groupName}</b></tt>\r
87      * (or the configured <tt><b>{@link Ext.grid.Column#header header}</b></tt> if not provided) configured in the\r
88      * {@link Ext.grid.Column} for each set of grouped rows (defaults to <tt>true</tt>).\r
89      */\r
90     showGroupName : true,\r
91     <div id="cfg-Ext.grid.GroupingView-startCollapsed"></div>/**\r
92      * @cfg {Boolean} startCollapsed <tt>true</tt> to start all groups collapsed (defaults to <tt>false</tt>)\r
93      */\r
94     startCollapsed : false,\r
95     <div id="cfg-Ext.grid.GroupingView-enableGrouping"></div>/**\r
96      * @cfg {Boolean} enableGrouping <tt>false</tt> to disable grouping functionality (defaults to <tt>true</tt>)\r
97      */\r
98     enableGrouping : true,\r
99     <div id="cfg-Ext.grid.GroupingView-enableGroupingMenu"></div>/**\r
100      * @cfg {Boolean} enableGroupingMenu <tt>true</tt> to enable the grouping control in the column menu (defaults to <tt>true</tt>)\r
101      */\r
102     enableGroupingMenu : true,\r
103     <div id="cfg-Ext.grid.GroupingView-enableNoGroups"></div>/**\r
104      * @cfg {Boolean} enableNoGroups <tt>true</tt> to allow the user to turn off grouping (defaults to <tt>true</tt>)\r
105      */\r
106     enableNoGroups : true,\r
107     <div id="cfg-Ext.grid.GroupingView-emptyGroupText"></div>/**\r
108      * @cfg {String} emptyGroupText The text to display when there is an empty group value (defaults to <tt>'(None)'</tt>).\r
109      * May also be specified per column, see {@link Ext.grid.Column}.{@link Ext.grid.Column#emptyGroupText emptyGroupText}.\r
110      */\r
111     emptyGroupText : '(None)',\r
112     <div id="cfg-Ext.grid.GroupingView-ignoreAdd"></div>/**\r
113      * @cfg {Boolean} ignoreAdd <tt>true</tt> to skip refreshing the view when new rows are added (defaults to <tt>false</tt>)\r
114      */\r
115     ignoreAdd : false,\r
116     <div id="cfg-Ext.grid.GroupingView-groupTextTpl"></div>/**\r
117      * @cfg {String} groupTextTpl The template used to render the group header (defaults to <tt>'{text}'</tt>).\r
118      * This is used to format an object which contains the following properties:\r
119      * <div class="mdetail-params"><ul>\r
120      * <li><b>group</b> : String<p class="sub-desc">The <i>rendered</i> value of the group field.\r
121      * By default this is the unchanged value of the group field. If a <tt><b>{@link Ext.grid.Column#groupRenderer groupRenderer}</b></tt>\r
122      * is specified, it is the result of a call to that function.</p></li>\r
123      * <li><b>gvalue</b> : Object<p class="sub-desc">The <i>raw</i> value of the group field.</p></li>\r
124      * <li><b>text</b> : String<p class="sub-desc">The configured header (as described in <tt>{@link #showGroupName})</tt>\r
125      * if <tt>{@link #showGroupName}</tt> is <tt>true</tt>) plus the <i>rendered</i> group field value.</p></li>\r
126      * <li><b>groupId</b> : String<p class="sub-desc">A unique, generated ID which is applied to the\r
127      * View Element which contains the group.</p></li>\r
128      * <li><b>startRow</b> : Number<p class="sub-desc">The row index of the Record which caused group change.</p></li>\r
129      * <li><b>rs</b> : Array<p class="sub-desc">Contains a single element: The Record providing the data\r
130      * for the row which caused group change.</p></li>\r
131      * <li><b>cls</b> : String<p class="sub-desc">The generated class name string to apply to the group header Element.</p></li>\r
132      * <li><b>style</b> : String<p class="sub-desc">The inline style rules to apply to the group header Element.</p></li>\r
133      * </ul></div></p>\r
134      * See {@link Ext.XTemplate} for information on how to format data using a template. Possible usage:<pre><code>\r
135 var grid = new Ext.grid.GridPanel({\r
136     ...\r
137     view: new Ext.grid.GroupingView({\r
138         groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'\r
139     }),\r
140 });\r
141      * </code></pre>\r
142      */\r
143     groupTextTpl : '{text}',\r
144 \r
145     <div id="cfg-Ext.grid.GroupingView-groupMode"></div>/**\r
146      * @cfg {String} groupMode Indicates how to construct the group identifier. <tt>'value'</tt> constructs the id using\r
147      * raw value, <tt>'display'</tt> constructs the id using the rendered value. Defaults to <tt>'value'</tt>.\r
148      */\r
149     groupMode: 'value',\r
150 \r
151     <div id="cfg-Ext.grid.GroupingView-groupRenderer"></div>/**\r
152      * @cfg {Function} groupRenderer This property must be configured in the {@link Ext.grid.Column} for\r
153      * each column.\r
154      */\r
155 \r
156     // private\r
157     gidSeed : 1000,\r
158 \r
159     // private\r
160     initTemplates : function(){\r
161         Ext.grid.GroupingView.superclass.initTemplates.call(this);\r
162         this.state = {};\r
163 \r
164         var sm = this.grid.getSelectionModel();\r
165         sm.on(sm.selectRow ? 'beforerowselect' : 'beforecellselect',\r
166                 this.onBeforeRowSelect, this);\r
167 \r
168         if(!this.startGroup){\r
169             this.startGroup = new Ext.XTemplate(\r
170                 '<div id="{groupId}" class="x-grid-group {cls}">',\r
171                     '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div class="x-grid-group-title">', this.groupTextTpl ,'</div></div>',\r
172                     '<div id="{groupId}-bd" class="x-grid-group-body">'\r
173             );\r
174         }\r
175         this.startGroup.compile();\r
176         if(!this.endGroup){\r
177             this.endGroup = '</div></div>';\r
178         }\r
179 \r
180         this.endGroup = '</div></div>';\r
181     },\r
182 \r
183     // private\r
184     findGroup : function(el){\r
185         return Ext.fly(el).up('.x-grid-group', this.mainBody.dom);\r
186     },\r
187 \r
188     // private\r
189     getGroups : function(){\r
190         return this.hasRows() ? this.mainBody.dom.childNodes : [];\r
191     },\r
192 \r
193     // private\r
194     onAdd : function(){\r
195         if(this.enableGrouping && !this.ignoreAdd){\r
196             var ss = this.getScrollState();\r
197             this.refresh();\r
198             this.restoreScroll(ss);\r
199         }else if(!this.enableGrouping){\r
200             Ext.grid.GroupingView.superclass.onAdd.apply(this, arguments);\r
201         }\r
202     },\r
203 \r
204     // private\r
205     onRemove : function(ds, record, index, isUpdate){\r
206         Ext.grid.GroupingView.superclass.onRemove.apply(this, arguments);\r
207         var g = document.getElementById(record._groupId);\r
208         if(g && g.childNodes[1].childNodes.length < 1){\r
209             Ext.removeNode(g);\r
210         }\r
211         this.applyEmptyText();\r
212     },\r
213 \r
214     // private\r
215     refreshRow : function(record){\r
216         if(this.ds.getCount()==1){\r
217             this.refresh();\r
218         }else{\r
219             this.isUpdating = true;\r
220             Ext.grid.GroupingView.superclass.refreshRow.apply(this, arguments);\r
221             this.isUpdating = false;\r
222         }\r
223     },\r
224 \r
225     // private\r
226     beforeMenuShow : function(){\r
227         var item, items = this.hmenu.items, disabled = this.cm.config[this.hdCtxIndex].groupable === false;\r
228         if((item = items.get('groupBy'))){\r
229             item.setDisabled(disabled);\r
230         }\r
231         if((item = items.get('showGroups'))){\r
232             item.setDisabled(disabled);\r
233         item.setChecked(this.enableGrouping, true);\r
234         }\r
235     },\r
236 \r
237     // private\r
238     renderUI : function(){\r
239         Ext.grid.GroupingView.superclass.renderUI.call(this);\r
240         this.mainBody.on('mousedown', this.interceptMouse, this);\r
241 \r
242         if(this.enableGroupingMenu && this.hmenu){\r
243             this.hmenu.add('-',{\r
244                 itemId:'groupBy',\r
245                 text: this.groupByText,\r
246                 handler: this.onGroupByClick,\r
247                 scope: this,\r
248                 iconCls:'x-group-by-icon'\r
249             });\r
250             if(this.enableNoGroups){\r
251                 this.hmenu.add({\r
252                     itemId:'showGroups',\r
253                     text: this.showGroupsText,\r
254             checked: true,\r
255                     checkHandler: this.onShowGroupsClick,\r
256                     scope: this\r
257                 });\r
258             }\r
259             this.hmenu.on('beforeshow', this.beforeMenuShow, this);\r
260         }\r
261     },\r
262 \r
263     processEvent: function(name, e){\r
264         var hd = e.getTarget('.x-grid-group-hd', this.mainBody);\r
265         if(hd){\r
266             // group value is at the end of the string\r
267             var field = this.getGroupField(),\r
268                 prefix = this.getPrefix(field),\r
269                 groupValue = hd.id.substring(prefix.length);\r
270 \r
271             // remove trailing '-hd'\r
272             groupValue = groupValue.substr(0, groupValue.length - 3);\r
273             if(groupValue){\r
274                 this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);\r
275             }\r
276         }\r
277 \r
278     },\r
279 \r
280     // private\r
281     onGroupByClick : function(){\r
282     this.enableGrouping = true;\r
283         this.grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));\r
284         this.beforeMenuShow(); // Make sure the checkboxes get properly set when changing groups\r
285     this.refresh();\r
286     },\r
287 \r
288     // private\r
289     onShowGroupsClick : function(mi, checked){\r
290     this.enableGrouping = checked;\r
291         if(checked){\r
292             this.onGroupByClick();\r
293         }else{\r
294             this.grid.store.clearGrouping();\r
295         }\r
296     },\r
297 \r
298     <div id="method-Ext.grid.GroupingView-toggleRowIndex"></div>/**\r
299      * Toggle the group that contains the specific row.\r
300      * @param {Number} rowIndex The row inside the group\r
301      * @param {Boolean} expanded (optional)\r
302      */\r
303     toggleRowIndex : function(rowIndex, expanded){\r
304         if(!this.enableGrouping){\r
305             return;\r
306         }\r
307         var row = this.getRow(rowIndex);\r
308         if(row){\r
309             this.toggleGroup(this.findGroup(row), expanded);\r
310         }\r
311     },\r
312 \r
313     <div id="method-Ext.grid.GroupingView-toggleGroup"></div>/**\r
314      * Toggles the specified group if no value is passed, otherwise sets the expanded state of the group to the value passed.\r
315      * @param {String} groupId The groupId assigned to the group (see getGroupId)\r
316      * @param {Boolean} expanded (optional)\r
317      */\r
318     toggleGroup : function(group, expanded){\r
319         var gel = Ext.get(group);\r
320         expanded = Ext.isDefined(expanded) ? expanded : gel.hasClass('x-grid-group-collapsed');\r
321         if(this.state[gel.id] !== expanded){\r
322             this.grid.stopEditing(true);\r
323             this.state[gel.id] = expanded;\r
324             gel[expanded ? 'removeClass' : 'addClass']('x-grid-group-collapsed');\r
325         }\r
326     },\r
327 \r
328     <div id="method-Ext.grid.GroupingView-toggleAllGroups"></div>/**\r
329      * Toggles all groups if no value is passed, otherwise sets the expanded state of all groups to the value passed.\r
330      * @param {Boolean} expanded (optional)\r
331      */\r
332     toggleAllGroups : function(expanded){\r
333         var groups = this.getGroups();\r
334         for(var i = 0, len = groups.length; i < len; i++){\r
335             this.toggleGroup(groups[i], expanded);\r
336         }\r
337     },\r
338 \r
339     <div id="method-Ext.grid.GroupingView-expandAllGroups"></div>/**\r
340      * Expands all grouped rows.\r
341      */\r
342     expandAllGroups : function(){\r
343         this.toggleAllGroups(true);\r
344     },\r
345 \r
346     <div id="method-Ext.grid.GroupingView-collapseAllGroups"></div>/**\r
347      * Collapses all grouped rows.\r
348      */\r
349     collapseAllGroups : function(){\r
350         this.toggleAllGroups(false);\r
351     },\r
352 \r
353     // private\r
354     interceptMouse : function(e){\r
355         var hd = e.getTarget('.x-grid-group-hd', this.mainBody);\r
356         if(hd){\r
357             e.stopEvent();\r
358             this.toggleGroup(hd.parentNode);\r
359         }\r
360     },\r
361 \r
362     // private\r
363     getGroup : function(v, r, groupRenderer, rowIndex, colIndex, ds){\r
364         var g = groupRenderer ? groupRenderer(v, {}, r, rowIndex, colIndex, ds) : String(v);\r
365         if(g === '' || g === '&#160;'){\r
366             g = this.cm.config[colIndex].emptyGroupText || this.emptyGroupText;\r
367         }\r
368         return g;\r
369     },\r
370 \r
371     // private\r
372     getGroupField : function(){\r
373         return this.grid.store.getGroupState();\r
374     },\r
375 \r
376     // private\r
377     afterRender : function(){\r
378         Ext.grid.GroupingView.superclass.afterRender.call(this);\r
379         if(this.grid.deferRowRender){\r
380             this.updateGroupWidths();\r
381         }\r
382     },\r
383 \r
384     // private\r
385     renderRows : function(){\r
386         var groupField = this.getGroupField();\r
387         var eg = !!groupField;\r
388         // if they turned off grouping and the last grouped field is hidden\r
389         if(this.hideGroupedColumn) {\r
390             var colIndex = this.cm.findColumnIndex(groupField),\r
391                 hasLastGroupField = Ext.isDefined(this.lastGroupField);\r
392             if(!eg && hasLastGroupField){\r
393                 this.mainBody.update('');\r
394                 this.cm.setHidden(this.cm.findColumnIndex(this.lastGroupField), false);\r
395                 delete this.lastGroupField;\r
396             }else if (eg && !hasLastGroupField){\r
397                 this.lastGroupField = groupField;\r
398                 this.cm.setHidden(colIndex, true);\r
399             }else if (eg && hasLastGroupField && groupField !== this.lastGroupField) {\r
400                 this.mainBody.update('');\r
401                 var oldIndex = this.cm.findColumnIndex(this.lastGroupField);\r
402                 this.cm.setHidden(oldIndex, false);\r
403                 this.lastGroupField = groupField;\r
404                 this.cm.setHidden(colIndex, true);\r
405             }\r
406         }\r
407         return Ext.grid.GroupingView.superclass.renderRows.apply(\r
408                     this, arguments);\r
409     },\r
410 \r
411     // private\r
412     doRender : function(cs, rs, ds, startRow, colCount, stripe){\r
413         if(rs.length < 1){\r
414             return '';\r
415         }\r
416         var groupField = this.getGroupField(),\r
417             colIndex = this.cm.findColumnIndex(groupField),\r
418             g;\r
419 \r
420         this.enableGrouping = (this.enableGrouping === false) ? false : !!groupField;\r
421 \r
422         if(!this.enableGrouping || this.isUpdating){\r
423             return Ext.grid.GroupingView.superclass.doRender.apply(\r
424                     this, arguments);\r
425         }\r
426         var gstyle = 'width:' + this.getTotalWidth() + ';',\r
427             cfg = this.cm.config[colIndex],\r
428             groupRenderer = cfg.groupRenderer || cfg.renderer,\r
429             prefix = this.showGroupName ? (cfg.groupName || cfg.header)+': ' : '',\r
430             groups = [],\r
431             curGroup, i, len, gid;\r
432 \r
433         for(i = 0, len = rs.length; i < len; i++){\r
434             var rowIndex = startRow + i,\r
435                 r = rs[i],\r
436                 gvalue = r.data[groupField];\r
437 \r
438                 g = this.getGroup(gvalue, r, groupRenderer, rowIndex, colIndex, ds);\r
439             if(!curGroup || curGroup.group != g){\r
440                 gid = this.constructId(gvalue, groupField, colIndex);\r
441                 // if state is defined use it, however state is in terms of expanded\r
442                 // so negate it, otherwise use the default.\r
443                 this.state[gid] = !(Ext.isDefined(this.state[gid]) ? !this.state[gid] : this.startCollapsed);\r
444                 curGroup = {\r
445                     group: g,\r
446                     gvalue: gvalue,\r
447                     text: prefix + g,\r
448                     groupId: gid,\r
449                     startRow: rowIndex,\r
450                     rs: [r],\r
451                     cls: this.state[gid] ? '' : 'x-grid-group-collapsed',\r
452                     style: gstyle\r
453                 };\r
454                 groups.push(curGroup);\r
455             }else{\r
456                 curGroup.rs.push(r);\r
457             }\r
458             r._groupId = gid;\r
459         }\r
460 \r
461         var buf = [];\r
462         for(i = 0, len = groups.length; i < len; i++){\r
463             g = groups[i];\r
464             this.doGroupStart(buf, g, cs, ds, colCount);\r
465             buf[buf.length] = Ext.grid.GroupingView.superclass.doRender.call(\r
466                     this, cs, g.rs, ds, g.startRow, colCount, stripe);\r
467 \r
468             this.doGroupEnd(buf, g, cs, ds, colCount);\r
469         }\r
470         return buf.join('');\r
471     },\r
472 \r
473     <div id="method-Ext.grid.GroupingView-getGroupId"></div>/**\r
474      * Dynamically tries to determine the groupId of a specific value\r
475      * @param {String} value\r
476      * @return {String} The group id\r
477      */\r
478     getGroupId : function(value){\r
479         var field = this.getGroupField();\r
480         return this.constructId(value, field, this.cm.findColumnIndex(field));\r
481     },\r
482 \r
483     // private\r
484     constructId : function(value, field, idx){\r
485         var cfg = this.cm.config[idx],\r
486             groupRenderer = cfg.groupRenderer || cfg.renderer,\r
487             val = (this.groupMode == 'value') ? value : this.getGroup(value, {data:{}}, groupRenderer, 0, idx, this.ds);\r
488 \r
489         return this.getPrefix(field) + Ext.util.Format.htmlEncode(val);\r
490     },\r
491 \r
492     // private\r
493     getPrefix: function(field){\r
494         return this.grid.getGridEl().id + '-gp-' + field + '-';\r
495     },\r
496 \r
497     // private\r
498     doGroupStart : function(buf, g, cs, ds, colCount){\r
499         buf[buf.length] = this.startGroup.apply(g);\r
500     },\r
501 \r
502     // private\r
503     doGroupEnd : function(buf, g, cs, ds, colCount){\r
504         buf[buf.length] = this.endGroup;\r
505     },\r
506 \r
507     // private\r
508     getRows : function(){\r
509         if(!this.enableGrouping){\r
510             return Ext.grid.GroupingView.superclass.getRows.call(this);\r
511         }\r
512         var r = [];\r
513         var g, gs = this.getGroups();\r
514         for(var i = 0, len = gs.length; i < len; i++){\r
515             g = gs[i].childNodes[1].childNodes;\r
516             for(var j = 0, jlen = g.length; j < jlen; j++){\r
517                 r[r.length] = g[j];\r
518             }\r
519         }\r
520         return r;\r
521     },\r
522 \r
523     // private\r
524     updateGroupWidths : function(){\r
525         if(!this.enableGrouping || !this.hasRows()){\r
526             return;\r
527         }\r
528         var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.getScrollOffset()) +'px';\r
529         var gs = this.getGroups();\r
530         for(var i = 0, len = gs.length; i < len; i++){\r
531             gs[i].firstChild.style.width = tw;\r
532         }\r
533     },\r
534 \r
535     // private\r
536     onColumnWidthUpdated : function(col, w, tw){\r
537         Ext.grid.GroupingView.superclass.onColumnWidthUpdated.call(this, col, w, tw);\r
538         this.updateGroupWidths();\r
539     },\r
540 \r
541     // private\r
542     onAllColumnWidthsUpdated : function(ws, tw){\r
543         Ext.grid.GroupingView.superclass.onAllColumnWidthsUpdated.call(this, ws, tw);\r
544         this.updateGroupWidths();\r
545     },\r
546 \r
547     // private\r
548     onColumnHiddenUpdated : function(col, hidden, tw){\r
549         Ext.grid.GroupingView.superclass.onColumnHiddenUpdated.call(this, col, hidden, tw);\r
550         this.updateGroupWidths();\r
551     },\r
552 \r
553     // private\r
554     onLayout : function(){\r
555         this.updateGroupWidths();\r
556     },\r
557 \r
558     // private\r
559     onBeforeRowSelect : function(sm, rowIndex){\r
560         this.toggleRowIndex(rowIndex, true);\r
561     }\r
562 });\r
563 // private\r
564 Ext.grid.GroupingView.GROUP_ID = 1000;</pre>    \r
565 </body>\r
566 </html>