]> git.proxmox.com Git - extjs.git/blame - extjs/examples/kitchensink/classic/samples/view/pivot/RemoteCalculations.js
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / kitchensink / classic / samples / view / pivot / RemoteCalculations.js
CommitLineData
6527f429
DM
1/**\r
2 *\r
3 * This example shows how to create a pivot grid with remote calculations\r
4 * and how to drill down the results.\r
5 *\r
6 * DblClick a cell to open the drill down window and see all records used to\r
7 * aggregate that cell.\r
8 *\r
9 */\r
10Ext.define('KitchenSink.view.pivot.RemoteCalculations', {\r
11 extend: 'Ext.pivot.Grid',\r
12 xtype: 'remote-pivot-grid',\r
13 controller: 'remotecalculations',\r
14\r
15 requires: [\r
16 'KitchenSink.view.pivot.RemoteCalculationsController'\r
17 ],\r
18\r
19 title: 'Remote calculations',\r
20 collapsible: true,\r
21 multiSelect: true,\r
22 height: 350,\r
23\r
24 selModel: {\r
25 type: 'spreadsheet'\r
26 },\r
27\r
28 // Set matrix specific configuration\r
29 matrixConfig: {\r
30 type: 'remote',\r
31 url: '/KitchenSink/RemoteSalesData'\r
32 },\r
33\r
34 plugins: [{\r
35 ptype: 'pivotdrilldown',\r
36 // define the columns used by the grid\r
37 columns: [\r
38 {dataIndex: 'company', text: 'Company'},\r
39 {dataIndex: 'continent', text: 'Continent'},\r
40 {dataIndex: 'country', text: 'Country'},\r
41 {dataIndex: 'person', text: 'Person'},\r
42 {dataIndex: 'date', text: 'Date', xtype: 'datecolumn'},\r
43 {dataIndex: 'value', text: 'Value', xtype: 'numbercolumn', align: 'right'},\r
44 {dataIndex: 'quantity', text: 'Qty', xtype: 'numbercolumn', align: 'right'},\r
45 {dataIndex: 'year', text: 'Year', xtype: 'numbercolumn', formatter: 'number(0)', align: 'right'},\r
46 {dataIndex: 'month', text: 'Month', xtype: 'numbercolumn', formatter: 'number(0)', align: 'right'}\r
47 ],\r
48\r
49 // define a remote store that will be used to filter the records\r
50 remoteStore: {\r
51 model: 'KitchenSink.model.pivot.Sale',\r
52\r
53 proxy: {\r
54 // load using HTTP\r
55 type: 'ajax',\r
56 url: '/KitchenSink/RemoteSalesData',\r
57 // the return will be JSON, so lets set up a reader\r
58 reader: {\r
59 type: 'json',\r
60 rootProperty: 'data'\r
61 }\r
62 }\r
63 }\r
64 }],\r
65\r
66 // Set layout type to "outline". If this config is missing then the default layout is "outline"\r
67 viewLayoutType: 'outline',\r
68\r
69 // Set this to false if multiple dimensions are configured on leftAxis and\r
70 // you want to automatically expand the row groups when calculations are ready.\r
71 startRowGroupsCollapsed: false,\r
72\r
73 // Configure the aggregate dimensions. Multiple dimensions are supported.\r
74 aggregate: [{\r
75 // id was provided for a better understanding of the JSON response\r
76 id: 'valueAgg',\r
77 dataIndex: 'value',\r
78 header: 'Sum of value',\r
79 aggregator: 'sum',\r
80 width: 90\r
81 },{\r
82 // id was provided for a better understanding of the JSON response\r
83 id: 'countAgg',\r
84 dataIndex: 'id',\r
85 header: 'Count',\r
86 aggregator: 'count',\r
87 width: 80\r
88 }],\r
89\r
90 // Configure the left axis dimensions that will be used to generate the grid rows\r
91 leftAxis: [{\r
92 // id was provided for a better understanding of the JSON response\r
93 id: 'person',\r
94 dataIndex: 'person',\r
95 header: 'Person',\r
96 width: 80\r
97 },{\r
98 // id was provided for a better understanding of the JSON response\r
99 id: 'company',\r
100 dataIndex: 'company',\r
101 header: 'Company',\r
102 sortable: false,\r
103 width: 80\r
104 }],\r
105\r
106 /**\r
107 * Configure the top axis dimensions that will be used to generate the columns.\r
108 * When columns are generated the aggregate dimensions are also used. If multiple aggregation dimensions\r
109 * are defined then each top axis result will have in the end a column header with children\r
110 * columns for each aggregate dimension defined.\r
111 */\r
112 topAxis: [{\r
113 // id was provided for a better understanding of the JSON response\r
114 id: 'country',\r
115 dataIndex: 'country',\r
116 header: 'Country'\r
117 }],\r
118\r
119 listeners: {\r
120 pivotdone: 'onPivotDone'\r
121 },\r
122\r
123 //<example>\r
124 otherContent: [{\r
125 type: 'Controller',\r
126 path: 'classic/samples/view/pivot/RemoteCalculationsController.js'\r
127 }],\r
128 profiles: {\r
129 classic: {\r
130 width: 600\r
131 },\r
132 neptune: {\r
133 width: 750\r
134 }\r
135 },\r
136 //</example>\r
137\r
138 initComponent: function () {\r
139 var me = this;\r
140\r
141 me.width = me.profileInfo.width;\r
142\r
143 me.callParent();\r
144 }\r
145});\r