X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/src/widgets/grid/GroupingView.js diff --git a/src/widgets/grid/GroupingView.js b/src/widgets/grid/GroupingView.js index b42863d7..e2d87b36 100644 --- a/src/widgets/grid/GroupingView.js +++ b/src/widgets/grid/GroupingView.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.0 + * Ext JS Library 3.0.3 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -139,6 +139,13 @@ var grid = new Ext.grid.GridPanel({ * */ groupTextTpl : '{text}', + + /** + * @cfg {String} groupMode Indicates how to construct the group identifier. 'value' constructs the id using + * raw value, 'display' constructs the id using the rendered value. Defaults to 'value'. + */ + groupMode: 'value', + /** * @cfg {Function} groupRenderer This property must be configured in the {@link Ext.grid.Column} for * each column. @@ -315,7 +322,7 @@ var grid = new Ext.grid.GridPanel({ // private getGroup : function(v, r, groupRenderer, rowIndex, colIndex, ds){ var g = groupRenderer ? groupRenderer(v, {}, r, rowIndex, colIndex, ds) : String(v); - if(g === ''){ + if(g === '' || g === ' '){ g = this.cm.config[colIndex].emptyGroupText || this.emptyGroupText; } return g; @@ -375,15 +382,14 @@ var grid = new Ext.grid.GridPanel({ return Ext.grid.GroupingView.superclass.doRender.apply( this, arguments); } - var gstyle = 'width:'+this.getTotalWidth()+';'; - - var gidPrefix = this.grid.getGridEl().id; - var cfg = this.cm.config[colIndex]; - var groupRenderer = cfg.groupRenderer || cfg.renderer; - var prefix = this.showGroupName ? - (cfg.groupName || cfg.header)+': ' : ''; + var gstyle = 'width:' + this.getTotalWidth() + ';', + gidPrefix = this.grid.getGridEl().id, + cfg = this.cm.config[colIndex], + groupRenderer = cfg.groupRenderer || cfg.renderer, + prefix = this.showGroupName ? (cfg.groupName || cfg.header)+': ' : '', + groups = [], + curGroup, i, len, gid; - var groups = [], curGroup, i, len, gid; for(i = 0, len = rs.length; i < len; i++){ var rowIndex = startRow + i, r = rs[i], @@ -391,7 +397,7 @@ var grid = new Ext.grid.GridPanel({ g = this.getGroup(gvalue, r, groupRenderer, rowIndex, colIndex, ds); if(!curGroup || curGroup.group != g){ - gid = gidPrefix + '-gp-' + groupField + '-' + Ext.util.Format.htmlEncode(g); + gid = this.constructId(gvalue, gidPrefix, groupField, colIndex); // if state is defined use it, however state is in terms of expanded // so negate it, otherwise use the default. var isCollapsed = typeof this.state[gid] !== 'undefined' ? !this.state[gid] : this.startCollapsed; @@ -431,13 +437,17 @@ var grid = new Ext.grid.GridPanel({ * @return {String} The group id */ getGroupId : function(value){ - var gidPrefix = this.grid.getGridEl().id; - var groupField = this.getGroupField(); - var colIndex = this.cm.findColumnIndex(groupField); - var cfg = this.cm.config[colIndex]; - var groupRenderer = cfg.groupRenderer || cfg.renderer; - var gtext = this.getGroup(value, {data:{}}, groupRenderer, 0, colIndex, this.ds); - return gidPrefix + '-gp-' + groupField + '-' + Ext.util.Format.htmlEncode(value); + var field = this.getGroupField(); + return this.constructId(value, this.grid.getGridEl().id, field, this.cm.findColumnIndex(field)); + }, + + // private + constructId : function(value, prefix, field, idx){ + var cfg = this.cm.config[idx], + groupRenderer = cfg.groupRenderer || cfg.renderer, + val = (this.groupMode == 'value') ? value : this.getGroup(value, {data:{}}, groupRenderer, 0, idx, this.ds); + + return prefix + '-gp-' + field + '-' + Ext.util.Format.htmlEncode(val); }, // private @@ -471,7 +481,7 @@ var grid = new Ext.grid.GridPanel({ if(!this.enableGrouping || !this.hasRows()){ return; } - var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.scrollOffset) +'px'; + var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.getScrollOffset()) +'px'; var gs = this.getGroups(); for(var i = 0, len = gs.length; i < len; i++){ gs[i].firstChild.style.width = tw;