+++ /dev/null
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.data.GroupingStore\r
- * @extends Ext.data.Store\r
- * A specialized store implementation that provides for grouping records by one of the available fields. This\r
- * is usually used in conjunction with an {@link Ext.grid.GroupingView} to proved the data model for\r
- * a grouped GridPanel.\r
- * @constructor\r
- * Creates a new GroupingStore.\r
- * @param {Object} config A config object containing the objects needed for the Store to access data,\r
- * and read the data into Records.\r
- */\r
-Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {\r
- /**\r
- * @cfg {String} groupField\r
- * The field name by which to sort the store's data (defaults to '').\r
- */\r
- /**\r
- * @cfg {Boolean} remoteGroup\r
- * True if the grouping should apply on the server side, false if it is local only (defaults to false). If the\r
- * grouping is local, it can be applied immediately to the data. If it is remote, then it will simply act as a\r
- * helper, automatically sending the grouping field name as the 'groupBy' param with each XHR call.\r
- */\r
- remoteGroup : false,\r
- /**\r
- * @cfg {Boolean} groupOnSort\r
- * True to sort the data on the grouping field when a grouping operation occurs, false to sort based on the\r
- * existing sort info (defaults to false).\r
- */\r
- groupOnSort:false,\r
-\r
- /**\r
- * Clears any existing grouping and refreshes the data using the default sort.\r
- */\r
- clearGrouping : function(){\r
- this.groupField = false;\r
- if(this.remoteGroup){\r
- if(this.baseParams){\r
- delete this.baseParams.groupBy;\r
- }\r
- this.reload();\r
- }else{\r
- this.applySort();\r
- this.fireEvent('datachanged', this);\r
- }\r
- },\r
-\r
- /**\r
- * Groups the data by the specified field.\r
- * @param {String} field The field name by which to sort the store's data\r
- * @param {Boolean} forceRegroup (optional) True to force the group to be refreshed even if the field passed\r
- * in is the same as the current grouping field, false to skip grouping on the same field (defaults to false)\r
- */\r
- groupBy : function(field, forceRegroup){\r
- if(this.groupField == field && !forceRegroup){\r
- return; // already grouped by this field\r
- }\r
- this.groupField = field;\r
- if(this.remoteGroup){\r
- if(!this.baseParams){\r
- this.baseParams = {};\r
- }\r
- this.baseParams['groupBy'] = field;\r
- }\r
- if(this.groupOnSort){\r
- this.sort(field);\r
- return;\r
- }\r
- if(this.remoteGroup){\r
- this.reload();\r
- }else{\r
- var si = this.sortInfo || {};\r
- if(si.field != field){\r
- this.applySort();\r
- }else{\r
- this.sortData(field);\r
- }\r
- this.fireEvent('datachanged', this);\r
- }\r
- },\r
-\r
- // private\r
- applySort : function(){\r
- Ext.data.GroupingStore.superclass.applySort.call(this);\r
- if(!this.groupOnSort && !this.remoteGroup){\r
- var gs = this.getGroupState();\r
- if(gs && gs != this.sortInfo.field){\r
- this.sortData(this.groupField);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- applyGrouping : function(alwaysFireChange){\r
- if(this.groupField !== false){\r
- this.groupBy(this.groupField, true);\r
- return true;\r
- }else{\r
- if(alwaysFireChange === true){\r
- this.fireEvent('datachanged', this);\r
- }\r
- return false;\r
- }\r
- },\r
-\r
- // private\r
- getGroupState : function(){\r
- return this.groupOnSort && this.groupField !== false ?\r
- (this.sortInfo ? this.sortInfo.field : undefined) : this.groupField;\r
- }\r
-});
\ No newline at end of file