]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/kitchensink/classic/samples/view/pivot/Configurator.js
import ExtJS 7.0.0 GPL
[extjs.git] / extjs / build / examples / kitchensink / classic / samples / view / pivot / Configurator.js
CommitLineData
947f0963
TL
1/**
2 *
3 * This example shows how to create a pivot grid and let your end users
4 * configure it.
5 *
6 */
7Ext.define('KitchenSink.view.pivot.Configurator', {
8 extend: 'Ext.pivot.Grid',
9 xtype: 'configurable-pivot-grid',
10 controller: 'pivotconfig',
11
12 requires: [
13 'KitchenSink.view.pivot.ConfiguratorController',
14 'KitchenSink.store.pivot.Sales',
15 'Ext.pivot.plugin.Configurator'
16 ],
17
18 //<example>
19 otherContent: [{
20 type: 'Controller',
21 path: 'classic/samples/view/pivot/ConfiguratorController.js'
22 }, {
23 type: 'Model',
24 path: 'classic/samples/model/pivot/Sale.js'
25 }, {
26 type: 'Store',
27 path: 'classic/samples/store/pivot/Sales.js'
28 }],
29 profiles: {
30 classic: {
31 width: 600,
32 height: 350,
33 columnWidth: 100,
34 menuWidth: 100,
35 columnLines: true
36 },
37 neptune: {
38 width: 750,
39 height: 350,
40 columnWidth: 100,
41 menuWidth: 100,
42 columnLines: true
43 },
44 graphite: {
45 width: 950,
46 height: 600,
47 columnWidth: 120,
48 menuWidth: 120,
49 columnLines: true
50 },
51 'classic-material': {
52 width: 950,
53 height: 600,
54 columnWidth: 120,
55 menuWidth: 150,
56 columnLines: false
57 }
58 },
59 //</example>
60
61 title: 'Pivot Grid with Configurator plugin',
62 width: '${width}',
63 height: '${height}',
64 collapsible: true,
65 multiSelect: true,
66 columnLines: '${columnLines}',
67
68 selModel: {
69 type: 'spreadsheet'
70 },
71
72 plugins: {
73 pivotconfigurator: {
74 id: 'configurator',
75 // It is possible to configure a list of fields that can be used to
76 // configure the pivot grid
77 // If no fields list is supplied then all fields from the Store model
78 // are fetched automatically
79 fields: [{
80 dataIndex: 'quantity',
81 header: 'Qty',
82 // You can even provide a default aggregator function to be used
83 // when this field is dropped
84 // on the agg dimensions
85 aggregator: 'min',
86 formatter: 'number("0")',
87
88 settings: {
89 // Define here in which areas this field could be used
90 allowed: ['aggregate'],
91 // Set a custom style for this field to inform the user that
92 // it can be dragged only to "Values"
93 style: {
94 fontWeight: 'bold'
95 },
96 // Define here custom formatters that ca be used on this dimension
97 formatters: {
98 '0': 'number("0")',
99 '0%': 'number("0%")'
100 }
101 }
102 }, {
103 dataIndex: 'value',
104 header: 'Value',
105
106 settings: {
107 // Define here in which areas this field could be used
108 allowed: 'aggregate',
109 // Define here what aggregator functions can be used when this
110 // field is used as an aggregate dimension
111 aggregators: ['sum', 'avg', 'count'],
112 // Set a custom style for this field to inform the user that it
113 // can be dragged only to "Values"
114 style: {
115 fontWeight: 'bold'
116 },
117 // Define here custom renderers that can be used on this dimension
118 renderers: {
119 'Colored 0,000.00': 'coloredRenderer'
120 },
121 // Define here custom formatters that ca be used on this dimension
122 formatters: {
123 '0': 'number("0")',
124 '0.00': 'number("0.00")',
125 '0,000.00': 'number("0,000.00")',
126 '0%': 'number("0%")',
127 '0.00%': 'number("0.00%")'
128 }
129 }
130 }, {
131 dataIndex: 'company',
132 header: 'Company',
133
134 settings: {
135 // Define here what aggregator functions can be used when this
136 // field is used as an aggregate dimension
137 aggregators: ['count']
138 }
139 }, {
140 dataIndex: 'country',
141 header: 'Country',
142
143 settings: {
144 // Define here what aggregator functions can be used when this
145 // field is used as an aggregate dimension
146 aggregators: ['count']
147 }
148 }, {
149 dataIndex: 'person',
150 header: 'Person',
151
152 settings: {
153 // Define here what aggregator functions can be used when this
154 // field is used as an aggregate dimension
155 aggregators: 'count'
156 }
157 }, {
158 dataIndex: 'year',
159 header: 'Year',
160
161 settings: {
162 // Define here the areas in which this field is fixed and cannot
163 // be moved from
164 fixed: ['topAxis']
165 }
166 }, {
167 dataIndex: 'month',
168 header: 'Month',
169 labelRenderer: 'monthLabelRenderer',
170
171 settings: {
172 // Define here what aggregator functions can be used when this
173 // field is used as an aggregate dimension
174 aggregators: ['count'],
175 // Define here in which areas this field could be used
176 allowed: ['leftAxis', 'topAxis']
177 }
178 }]
179 }
180 },
181
182 matrix: {
183 type: 'local',
184 store: {
185 type: 'sales'
186 },
187
188 // Configure the aggregate dimensions. Multiple dimensions are supported.
189 aggregate: [{
190 dataIndex: 'value',
191 header: 'Value',
192 aggregator: 'avg',
193 width: '${columnWidth}'
194 }],
195
196 // Configure the left axis dimensions that will be used to generate
197 // the grid rows
198 leftAxis: [{
199 dataIndex: 'person',
200 header: 'Person'
201 }, {
202 dataIndex: 'company',
203 header: 'Company',
204 sortable: false,
205 width: '${columnWidth}'
206 }],
207
208 /**
209 * Configure the top axis dimensions that will be used to generate
210 * the columns.
211 *
212 * When columns are generated the aggregate dimensions are also used.
213 * If multiple aggregation dimensions are defined then each top axis
214 * result will have in the end a column header with children columns
215 * for each aggregate dimension defined.
216 */
217 topAxis: [{
218 dataIndex: 'year',
219 header: 'Year',
220 labelRenderer: 'yearLabelRenderer'
221 }]
222 },
223
224 listeners: {
225 // Define here a function that can add custom menu items to the
226 // configurator field menu
227 beforeshowconfigfieldmenu: 'getCustomMenus'
228 },
229
230 header: {
231 itemPosition: 1, // after title before collapse tool
232 items: [{
233 ui: 'default-toolbar',
234 xtype: 'button',
235 cls: 'dock-tab-btn',
236 text: 'Dock',
237 menu: {
238 defaults: {
239 xtype: 'menucheckitem',
240 group: 'docking',
241 checkHandler: 'changeDock'
242 },
243 width: '${menuWidth}',
244 items: [{
245 text: 'Top'
246 }, {
247 text: 'Right',
248 checked: true
249 }, {
250 text: 'Bottom'
251 }, {
252 text: 'Left'
253 }]
254 }
255 }]
256 }
257});