3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
8 * @class pivot.ConfigPanel
\r
10 * A configuration panel used for modifying the properties of a PivotGrid.
\r
12 pivot.ConfigPanel = Ext.extend(Ext.Panel, {
\r
19 * @cfg {Ext.data.Record} record The Ext.data.Record to extract the field list from. Required
\r
22 initComponent: function() {
\r
23 var fields = this.getRecordFields();
\r
27 * @type Ext.form.FormPanel
\r
28 * Used to set the measure and aggregation function
\r
30 this.form = new Ext.Container({
\r
32 style: 'padding: 7px',
\r
36 triggerAction: 'all',
\r
37 forceSelection: true,
\r
40 fieldLabel: 'Measure',
\r
43 displayField: 'name',
\r
45 value: this.measure || this.measures[0],
\r
46 store: this.getMeasureStore()
\r
47 }, {
\r xtype: 'combo',
\r
49 triggerAction: 'all',
\r forceSelection: true,
\r editable: false,
\r anchor: "0",
\r fieldLabel: 'Aggregator',
\r ref: '/aggregator',
\r
51 displayField: 'name',
\r valueField: 'value',
\r value: this.aggregator,
\r
52 store: new Ext.data.JsonStore({
\r
53 fields : ['name', 'value'],
\r
55 {name : 'Sum', value: 'sum'},
\r
56 {name : 'Count', value: 'count'},
\r
57 {name : 'Min', value: 'min'},
\r
58 {name : 'Max', value: 'max'},
\r
59 {name : 'Average', value: 'avg'}
\r
66 * @property leftAxisGrid
\r
67 * @type pivot.AxisGrid
\r
69 this.leftAxisGrid = new pivot.AxisGrid({
\r
70 title : 'Left Axis',
\r
72 dimensionData: this.leftAxisDimensions || [],
\r
77 * @property topAxisGrid
\r
78 * @type pivot.AxisGrid
\r
80 this.topAxisGrid = new pivot.AxisGrid({
\r
83 dimensionData: this.topAxisDimensions || []
\r
93 buttonAlign: 'left',
\r
95 icon : '../shared/icons/fam/accept.png',
\r
98 handler: this.updateGrid
\r
103 pivot.ConfigPanel.superclass.initComponent.apply(this, arguments);
\r
108 * Retrieves the configured axis dimensions for the top and left grids and updates the PivotGrid accordingly
\r
110 updateGrid: function() {
\r
111 var leftDimensions = [],
\r
112 topDimensions = [],
\r
113 leftGridItems = this.leftAxisGrid.store.data.items,
\r
114 topGridItems = this.topAxisGrid.store.data.items,
\r
117 for (i = 0; i < leftGridItems.length; i++) {
\r
118 leftDimensions.push({
\r
119 dataIndex: leftGridItems[i].get('field'),
\r
120 direction: leftGridItems[i].get('direction'),
\r
121 width : leftGridItems[i].get('width')
\r
125 for (i = 0; i < topGridItems.length; i++) {
\r
126 topDimensions.push({
\r
127 dataIndex: topGridItems[i].get('field'),
\r
128 direction: topGridItems[i].get('direction')
\r
132 this.fireEvent('update', {
\r
133 leftDimensions: leftDimensions,
\r
134 topDimensions : topDimensions,
\r
135 aggregator : this.aggregator.getValue(),
\r
136 measure : this.measure.getValue()
\r
141 * Extracts the field names from the configured record
\r
142 * @return {Array} The set of Record fields
\r
144 getRecordFields: function() {
\r
145 return Ext.pluck(this.record.prototype.fields.items, 'name');
\r
150 * @return {Ext.data.Store} The store
\r
152 getMeasureStore: function() {
\r
154 * @property measureStore
\r
155 * @type Ext.data.JsonStore
\r
156 * The store bound to the combo for selecting the field
\r
158 if (this.measureStore == undefined) {
\r
160 measures = this.measures,
\r
161 length = measures.length,
\r
164 for (i = 0; i < length; i++) {
\r
165 fields[i] = [measures[i]];
\r
168 this.measureStore = new Ext.data.ArrayStore({
\r
174 return this.measureStore;
\r
178 Ext.reg('pivotconfig', pivot.ConfigPanel);