]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/kitchensink/classic/samples/view/pivot/Configurator.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / kitchensink / classic / samples / view / pivot / Configurator.js
CommitLineData
6527f429
DM
1/**\r
2 *\r
3 * This example shows how to create a pivot grid and let your end users\r
4 * configure it.\r
5 *\r
6 */\r
7Ext.define('KitchenSink.view.pivot.Configurator', {\r
8 extend: 'Ext.pivot.Grid',\r
9 xtype: 'configurable-pivot-grid',\r
10 controller: 'pivotconfig',\r
11\r
12 requires: [\r
13 'KitchenSink.view.pivot.ConfiguratorController',\r
14 'KitchenSink.store.pivot.Sales',\r
15 'Ext.pivot.plugin.Configurator'\r
16 ],\r
17\r
18 title: 'Pivot Grid with Configurator plugin',\r
19 collapsible: true,\r
20 multiSelect: true,\r
21 height: 350,\r
22\r
23 store: {\r
24 type: 'sales'\r
25 },\r
26 selModel: {\r
27 type: 'spreadsheet'\r
28 },\r
29\r
30 plugins: [{\r
31 ptype: 'pivotconfigurator',\r
32 pluginId: 'configurator',\r
33 // It is possible to configure a list of fields that can be used to configure the pivot grid\r
34 // If no fields list is supplied then all fields from the Store model are fetched automatically\r
35 fields: [{\r
36 dataIndex: 'country',\r
37 header: 'Country'\r
38 }, {\r
39 dataIndex: 'quantity',\r
40 header: 'Qty',\r
41 // You can even provide a default aggregator function to be used when this field is dropped\r
42 // on the agg dimensions\r
43 aggregator: 'min'\r
44 }, {\r
45 dataIndex: 'month',\r
46 header: 'Month',\r
47 renderer: function(v, meta){\r
48 // This field can be dragged onto leftAxis or topAxis.\r
49 // When added to the topAxis the renderer is used to generate the column text, which\r
50 // means that only the value is passed to the function.\r
51 // When added to the leftAxis the renderer is called twice, once to generate the\r
52 // row labels and once by the grid panel so you can style the cell.\r
53 // To style an aggregated cell you need to add the renderer to the aggregate dimension.\r
54 return meta ? v : Ext.Date.monthNames[v];\r
55 }\r
56 }]\r
57 }],\r
58\r
59 // Configure the aggregate dimensions. Multiple dimensions are supported.\r
60 aggregate: [{\r
61 dataIndex: 'value',\r
62 header: 'Value',\r
63 aggregator: 'avg'\r
64 }],\r
65\r
66 // Configure the left axis dimensions that will be used to generate the grid rows\r
67 leftAxis: [{\r
68 dataIndex: 'person',\r
69 header: 'Person'\r
70 },{\r
71 dataIndex: 'company',\r
72 header: 'Company',\r
73 sortable: false\r
74 }],\r
75\r
76 /**\r
77 * Configure the top axis dimensions that will be used to generate the columns.\r
78 * When columns are generated the aggregate dimensions are also used. If multiple aggregation dimensions\r
79 * are defined then each top axis result will have in the end a column header with children\r
80 * columns for each aggregate dimension defined.\r
81 */\r
82 topAxis: [{\r
83 dataIndex: 'year',\r
84 header: 'Year'\r
85 }],\r
86\r
87 header: {\r
88 itemPosition: 1, // after title before collapse tool\r
89 items: [{\r
90 ui: 'default-toolbar',\r
91 xtype: 'button',\r
92 text: 'Dock',\r
93 menu: {\r
94 defaults: {\r
95 xtype: 'menucheckitem',\r
96 group: 'docking',\r
97 checkHandler: 'changeDock'\r
98 },\r
99 items: [{\r
100 text: 'Top'\r
101 },{\r
102 text: 'Right',\r
103 checked: true\r
104 },{\r
105 text: 'Bottom'\r
106 },{\r
107 text: 'Left'\r
108 }]\r
109 }\r
110 }]\r
111 },\r
112\r
113 //<example>\r
114 otherContent: [{\r
115 type: 'Controller',\r
116 path: 'classic/samples/view/pivot/ConfiguratorController.js'\r
117 },{\r
118 type: 'Model',\r
119 path: 'classic/samples/model/pivot/Sale.js'\r
120 },{\r
121 type: 'Store',\r
122 path: 'classic/samples/store/pivot/Sales.js'\r
123 }],\r
124 profiles: {\r
125 classic: {\r
126 width: 600\r
127 },\r
128 neptune: {\r
129 width: 750\r
130 }\r
131 },\r
132 //</example>\r
133\r
134 initComponent: function () {\r
135 var me = this;\r
136\r
137 me.width = me.profileInfo.width;\r
138\r
139 me.callParent();\r
140 }\r
141});\r