\r
// private\r
onAdd : function(){\r
- if(this.enableGrouping && !this.ignoreAdd){\r
+ if(this.canGroup() && !this.ignoreAdd){\r
var ss = this.getScrollState();\r
this.refresh();\r
this.restoreScroll(ss);\r
- }else if(!this.enableGrouping){\r
+ }else if(!this.canGroup()){\r
Ext.grid.GroupingView.superclass.onAdd.apply(this, arguments);\r
}\r
},\r
}\r
if((item = items.get('showGroups'))){\r
item.setDisabled(disabled);\r
- item.setChecked(this.enableGrouping, true);\r
+ item.setChecked(this.enableGrouping, true);\r
}\r
},\r
\r
this.hmenu.add({\r
itemId:'showGroups',\r
text: this.showGroupsText,\r
- checked: true,\r
+ checked: true,\r
checkHandler: this.onShowGroupsClick,\r
scope: this\r
});\r
\r
// private\r
onGroupByClick : function(){\r
- this.enableGrouping = true;\r
+ this.enableGrouping = true;\r
this.grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));\r
+ this.grid.fireEvent('groupchange', this, this.grid.store.getGroupState());\r
this.beforeMenuShow(); // Make sure the checkboxes get properly set when changing groups\r
- this.refresh();\r
+ this.refresh();\r
},\r
\r
// private\r
this.onGroupByClick();\r
}else{\r
this.grid.store.clearGrouping();\r
+ this.grid.fireEvent('groupchange', this, null);\r
}\r
},\r
\r
* @param {Boolean} expanded (optional)\r
*/\r
toggleRowIndex : function(rowIndex, expanded){\r
- if(!this.enableGrouping){\r
+ if(!this.canGroup()){\r
return;\r
}\r
var row = this.getRow(rowIndex);\r
\r
// private\r
afterRender : function(){\r
+ if(!this.ds || !this.cm){\r
+ return;\r
+ }\r
Ext.grid.GroupingView.superclass.afterRender.call(this);\r
if(this.grid.deferRowRender){\r
this.updateGroupWidths();\r
if(rs.length < 1){\r
return '';\r
}\r
- var groupField = this.getGroupField(),\r
- colIndex = this.cm.findColumnIndex(groupField),\r
- g;\r
-\r
- this.enableGrouping = (this.enableGrouping === false) ? false : !!groupField;\r
\r
- if(!this.enableGrouping || this.isUpdating){\r
+ if(!this.canGroup() || this.isUpdating){\r
return Ext.grid.GroupingView.superclass.doRender.apply(\r
this, arguments);\r
}\r
- var gstyle = 'width:' + this.getTotalWidth() + ';',\r
+\r
+ var groupField = this.getGroupField(),\r
+ colIndex = this.cm.findColumnIndex(groupField),\r
+ g,\r
+ gstyle = 'width:' + this.getTotalWidth() + ';',\r
cfg = this.cm.config[colIndex],\r
groupRenderer = cfg.groupRenderer || cfg.renderer,\r
prefix = this.showGroupName ? (cfg.groupName || cfg.header)+': ' : '',\r
return this.getPrefix(field) + Ext.util.Format.htmlEncode(val);\r
},\r
\r
+ // private\r
+ canGroup : function(){\r
+ return this.enableGrouping && !!this.getGroupField();\r
+ },\r
+\r
// private\r
getPrefix: function(field){\r
return this.grid.getGridEl().id + '-gp-' + field + '-';\r
\r
// private\r
getRows : function(){\r
- if(!this.enableGrouping){\r
+ if(!this.canGroup()){\r
return Ext.grid.GroupingView.superclass.getRows.call(this);\r
}\r
var r = [];\r
\r
// private\r
updateGroupWidths : function(){\r
- if(!this.enableGrouping || !this.hasRows()){\r
+ if(!this.canGroup() || !this.hasRows()){\r
return;\r
}\r
var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.getScrollOffset()) +'px';\r