3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.data.GroupingStore
11
* @extends Ext.data.Store
12
* A specialized store implementation that provides for grouping records by one of the available fields.
14
* Creates a new GroupingStore.
15
* @param {Object} config A config object containing the objects needed for the Store to access data,
16
* and read the data into Records.
18
Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {
20
* @cfg {String} groupField
21
* The field name by which to sort the store's data (defaults to '').
24
* @cfg {Boolean} remoteGroup
25
* True if the grouping should apply on the server side, false if it is local only (defaults to false). If the
26
* grouping is local, it can be applied immediately to the data. If it is remote, then it will simply act as a
27
* helper, automatically sending the grouping field name as the 'groupBy' param with each XHR call.
31
* @cfg {Boolean} groupOnSort
32
* True to sort the data on the grouping field when a grouping operation occurs, false to sort based on the
33
* existing sort info (defaults to false).
38
* Clears any existing grouping and refreshes the data using the default sort.
40
clearGrouping : function(){
41
this.groupField = false;
44
delete this.baseParams.groupBy;
49
this.fireEvent('datachanged', this);
54
* Groups the data by the specified field.
55
* @param {String} field The field name by which to sort the store's data
56
* @param {Boolean} forceRegroup (optional) True to force the group to be refreshed even if the field passed
57
* in is the same as the current grouping field, false to skip grouping on the same field (defaults to false)
59
groupBy : function(field, forceRegroup){
60
if(this.groupField == field && !forceRegroup){
61
return; // already grouped by this field
63
this.groupField = field;
68
this.baseParams['groupBy'] = field;
77
var si = this.sortInfo || {};
78
if(si.field != field){
83
this.fireEvent('datachanged', this);
88
applySort : function(){
89
Ext.data.GroupingStore.superclass.applySort.call(this);
90
if(!this.groupOnSort && !this.remoteGroup){
91
var gs = this.getGroupState();
92
if(gs && gs != this.sortInfo.field){
93
this.sortData(this.groupField);
99
applyGrouping : function(alwaysFireChange){
100
if(this.groupField !== false){
101
this.groupBy(this.groupField, true);
104
if(alwaysFireChange === true){
105
this.fireEvent('datachanged', this);
112
getGroupState : function(){
113
return this.groupOnSort && this.groupField !== false ?
114
(this.sortInfo ? this.sortInfo.field : undefined) : this.groupField;
b'\\ No newline at end of file'