-/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-/**\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
- * @xtype groupingstore\r
- */\r
-Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {\r
- \r
- //inherit docs\r
- constructor: function(config){\r
- Ext.data.GroupingStore.superclass.constructor.call(this, config);\r
- this.applyGroupField();\r
- },\r
- \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
- groupDir : 'ASC',\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
- var lo = this.lastOptions;\r
- if(lo && lo.params){\r
- delete lo.params.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, direction){\r
- direction = direction ? (String(direction).toUpperCase() == 'DESC' ? 'DESC' : 'ASC') : this.groupDir;\r
- if(this.groupField == field && this.groupDir == direction && !forceRegroup){\r
- return; // already grouped by this field\r
- }\r
- this.groupField = field;\r
- this.groupDir = direction;\r
- this.applyGroupField();\r
- if(this.groupOnSort){\r
- this.sort(field, direction);\r
- return;\r
- }\r
- if(this.remoteGroup){\r
- this.reload();\r
- }else{\r
- var si = this.sortInfo || {};\r
- if(si.field != field || si.direction != direction){\r
- this.applySort();\r
- }else{\r
- this.sortData(field, direction);\r
- }\r
- this.fireEvent('datachanged', this);\r
- }\r
- },\r
- \r
- // private\r
- applyGroupField: function(){\r
- if(this.remoteGroup){\r
- if(!this.baseParams){\r
- this.baseParams = {};\r
- }\r
- this.baseParams.groupBy = this.groupField;\r
- this.baseParams.groupDir = this.groupDir;\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 || this.groupDir != this.sortInfo.direction)){\r
- this.sortData(this.groupField, this.groupDir);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- applyGrouping : function(alwaysFireChange){\r
- if(this.groupField !== false){\r
- this.groupBy(this.groupField, true, this.groupDir);\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
-});\r
-Ext.reg('groupingstore', Ext.data.GroupingStore);
\ No newline at end of file