1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<html>
<head>
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
* Ext JS Library 3.0.3
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
<div id="cls-Ext.data.GroupingStore"></div>/**
* @class Ext.data.GroupingStore
* @extends Ext.data.Store
* A specialized store implementation that provides for grouping records by one of the available fields. This
* is usually used in conjunction with an {@link Ext.grid.GroupingView} to proved the data model for
* a grouped GridPanel.
* @constructor
* Creates a new GroupingStore.
* @param {Object} config A config object containing the objects needed for the Store to access data,
* and read the data into Records.
* @xtype groupingstore
*/
Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {
//inherit docs
constructor: function(config){
Ext.data.GroupingStore.superclass.constructor.call(this, config);
this.applyGroupField();
},
<div id="cfg-Ext.data.GroupingStore-groupField"></div>/**
* @cfg {String} groupField
* The field name by which to sort the store's data (defaults to '').
*/
<div id="cfg-Ext.data.GroupingStore-remoteGroup"></div>/**
* @cfg {Boolean} remoteGroup
* True if the grouping should apply on the server side, false if it is local only (defaults to false). If the
* grouping is local, it can be applied immediately to the data. If it is remote, then it will simply act as a
* helper, automatically sending the grouping field name as the 'groupBy' param with each XHR call.
*/
remoteGroup : false,
<div id="cfg-Ext.data.GroupingStore-groupOnSort"></div>/**
* @cfg {Boolean} groupOnSort
* True to sort the data on the grouping field when a grouping operation occurs, false to sort based on the
* existing sort info (defaults to false).
*/
groupOnSort:false,
groupDir : 'ASC',
<div id="method-Ext.data.GroupingStore-clearGrouping"></div>/**
* Clears any existing grouping and refreshes the data using the default sort.
*/
clearGrouping : function(){
this.groupField = false;
if(this.remoteGroup){
if(this.baseParams){
delete this.baseParams.groupBy;
}
var lo = this.lastOptions;
if(lo && lo.params){
delete lo.params.groupBy;
}
this.reload();
}else{
this.applySort();
this.fireEvent('datachanged', this);
}
},
<div id="method-Ext.data.GroupingStore-groupBy"></div>/**
* Groups the data by the specified field.
* @param {String} field The field name by which to sort the store's data
* @param {Boolean} forceRegroup (optional) True to force the group to be refreshed even if the field passed
* in is the same as the current grouping field, false to skip grouping on the same field (defaults to false)
*/
groupBy : function(field, forceRegroup, direction){
direction = direction ? (String(direction).toUpperCase() == 'DESC' ? 'DESC' : 'ASC') : this.groupDir;
if(this.groupField == field && this.groupDir == direction && !forceRegroup){
return; // already grouped by this field
}
this.groupField = field;
this.groupDir = direction;
this.applyGroupField();
if(this.groupOnSort){
this.sort(field, direction);
return;
}
if(this.remoteGroup){
this.reload();
}else{
var si = this.sortInfo || {};
if(si.field != field || si.direction != direction){
this.applySort();
}else{
this.sortData(field, direction);
}
this.fireEvent('datachanged', this);
}
},
// private
applyGroupField: function(){
if(this.remoteGroup){
if(!this.baseParams){
this.baseParams = {};
}
this.baseParams.groupBy = this.groupField;
this.baseParams.groupDir = this.groupDir;
}
},
// private
applySort : function(){
Ext.data.GroupingStore.superclass.applySort.call(this);
if(!this.groupOnSort && !this.remoteGroup){
var gs = this.getGroupState();
if(gs && (gs != this.sortInfo.field || this.groupDir != this.sortInfo.direction)){
this.sortData(this.groupField, this.groupDir);
}
}
},
// private
applyGrouping : function(alwaysFireChange){
if(this.groupField !== false){
this.groupBy(this.groupField, true, this.groupDir);
return true;
}else{
if(alwaysFireChange === true){
this.fireEvent('datachanged', this);
}
return false;
}
},
// private
getGroupState : function(){
return this.groupOnSort && this.groupField !== false ?
(this.sortInfo ? this.sortInfo.field : undefined) : this.groupField;
}
});
Ext.reg('groupingstore', Ext.data.GroupingStore);</pre>
</body>
</html>
|