]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * This is an example of using the Ext JS grid to show very large datasets\r | |
3 | * without overloading the DOM. It also uses locking columns, and incorporates the\r | |
4 | * GroupSummary feature. Filtering is enabled on certain columns using the FilterFeature.\r | |
5 | *\r | |
6 | * As an illustration of the ability of grid columns to act as containers, the Title\r | |
7 | * column has a filter text field built in which filters as you type.\r | |
8 | *\r | |
9 | * The grid is editable using the RowEditing plugin.\r | |
10 | *\r | |
11 | * The `multiColumnSort` config is used to allow multiple columns to have sorters.\r | |
12 | *\r | |
13 | * It is also possible to export the grid data to Excel. This feature is available in Ext JS Premium.\r | |
14 | */\r | |
15 | Ext.define('KitchenSink.view.grid.BigData', {\r | |
16 | extend: 'Ext.grid.Panel',\r | |
17 | requires: [\r | |
18 | 'Ext.grid.filters.Filters',\r | |
19 | 'Ext.grid.plugin.Exporter'\r | |
20 | ],\r | |
21 | xtype: 'big-data-grid',\r | |
22 | store: 'BigData',\r | |
23 | columnLines: true,\r | |
24 | height: 400,\r | |
25 | width: 910,\r | |
26 | title: 'Editable Big Data Grid',\r | |
27 | multiColumnSort: true,\r | |
28 | \r | |
29 | // We do not need automatic height synching.\r | |
30 | // The Grouping plugin renders the same DOM into each side to keep heights the same,\r | |
31 | // The normal side is visibility:hidden.\r | |
32 | // And the RowExpander handles this itself when a row is expanded, or when an expanded\r | |
33 | // row is scrolled back into the rendered block.\r | |
34 | syncRowHeight: false,\r | |
35 | \r | |
36 | //<example>\r | |
37 | exampleTitle: 'Editable Big Data Grid',\r | |
38 | otherContent: [{\r | |
39 | type: 'Controller',\r | |
40 | path: 'classic/samples/view/grid/BigDataController.js'\r | |
41 | },{\r | |
42 | type: 'Store',\r | |
43 | path: 'classic/samples/store/BigData.js'\r | |
44 | },{\r | |
45 | type: 'Model',\r | |
46 | path: 'classic/samples/model/grid/Employee.js'\r | |
47 | }],\r | |
48 | exampleDescription: [\r | |
49 | '<p>This example uses locking columns, and incorporates the GroupSummary feature.</p>' +\r | |
50 | '<p>Filtering is enabled on certain columns using the FilterFeature UX.</p>' +\r | |
51 | '<p>As an illustration of the ability of grid columns to act as containers, the ' +\r | |
52 | 'Title column has a filter text field built in which filters as you type.</p>' +\r | |
53 | '<p>The grid is editable using the RowEditing plugin.</p>',\r | |
54 | '<p>The <code>multiColumnSort</code> config is used to allow multiple columns to have sorters.</p>' +\r | |
55 | '<p>The full name column uses a custom sorter which sorts on the surname.</p>'\r | |
56 | ].join(''),\r | |
57 | //</example>\r | |
58 | controller: 'bigdata',\r | |
59 | \r | |
60 | features: [{\r | |
61 | ftype : 'groupingsummary',\r | |
62 | groupHeaderTpl : '{name}',\r | |
63 | hideGroupedHeader : false,\r | |
64 | enableGroupingMenu : false\r | |
65 | }, {\r | |
66 | ftype: 'summary',\r | |
67 | dock: 'bottom'\r | |
68 | }],\r | |
69 | \r | |
70 | selModel: {\r | |
71 | type: 'checkboxmodel',\r | |
72 | checkOnly: true\r | |
73 | },\r | |
74 | \r | |
75 | listeners: {\r | |
76 | headermenucreate: 'onHeaderMenuCreate'\r | |
77 | },\r | |
78 | \r | |
79 | columns:[{\r | |
80 | xtype: 'rownumberer',\r | |
81 | width: 40,\r | |
82 | sortable: false,\r | |
83 | locked: true\r | |
84 | }, {\r | |
85 | text: 'Id',\r | |
86 | sortable: true,\r | |
87 | dataIndex: 'employeeNo',\r | |
88 | groupable: false,\r | |
89 | width: 80,\r | |
90 | locked: true,\r | |
91 | editRenderer: 'bold'\r | |
92 | }, {\r | |
93 | text: 'Name (Filter)',\r | |
94 | sortable: true,\r | |
95 | dataIndex: 'name',\r | |
96 | groupable: false,\r | |
97 | width: 140,\r | |
98 | layout: 'hbox',\r | |
99 | locked: true,\r | |
100 | renderer: 'concatNames',\r | |
101 | editor: {\r | |
102 | xtype: 'textfield'\r | |
103 | },\r | |
104 | // Sort prioritizing surname over forename as would be expected.\r | |
105 | sorter: function(rec1, rec2) {\r | |
106 | var rec1Name = rec1.get('surname') + rec1.get('forename'),\r | |
107 | rec2Name = rec2.get('surname') + rec2.get('forename');\r | |
108 | \r | |
109 | if (rec1Name > rec2Name) {\r | |
110 | return 1;\r | |
111 | }\r | |
112 | if (rec1Name < rec2Name) {\r | |
113 | return -1;\r | |
114 | }\r | |
115 | return 0;\r | |
116 | },\r | |
117 | items : {\r | |
118 | xtype: 'textfield',\r | |
119 | reference: 'nameFilterField', // So that the Controller can access it easily\r | |
120 | flex : 1,\r | |
121 | margin: 2,\r | |
122 | enableKeyEvents: true,\r | |
123 | listeners: {\r | |
124 | keyup: 'onNameFilterKeyup',\r | |
125 | buffer: 500\r | |
126 | }\r | |
127 | }\r | |
128 | }, {\r | |
129 | text: 'Rating',\r | |
130 | width: 100,\r | |
131 | sortable: true,\r | |
132 | dataIndex: 'rating',\r | |
133 | groupable: false,\r | |
134 | xtype: 'widgetcolumn',\r | |
135 | widget: {\r | |
136 | xtype: 'sparklineline'\r | |
137 | }\r | |
138 | }, {\r | |
139 | text: 'Date of birth',\r | |
140 | dataIndex: 'dob',\r | |
141 | xtype: 'datecolumn',\r | |
142 | groupable: false,\r | |
143 | width: 115,\r | |
144 | filter: {\r | |
145 | \r | |
146 | },\r | |
147 | editor: {\r | |
148 | xtype: 'datefield'\r | |
149 | }\r | |
150 | }, {\r | |
151 | text: 'Join date',\r | |
152 | dataIndex: 'joinDate',\r | |
153 | xtype: 'datecolumn',\r | |
154 | groupable: false,\r | |
155 | width: 120,\r | |
156 | filter: {\r | |
157 | \r | |
158 | },\r | |
159 | editor: {\r | |
160 | xtype: 'datefield'\r | |
161 | }\r | |
162 | }, {\r | |
163 | text: 'Notice<br>period',\r | |
164 | dataIndex: 'noticePeriod',\r | |
165 | groupable: false,\r | |
166 | width: 115,\r | |
167 | filter: {\r | |
168 | type: 'list'\r | |
169 | },\r | |
170 | editor: {\r | |
171 | xtype: 'combobox',\r | |
172 | initComponent: function() {\r | |
173 | this.store = this.column.up('tablepanel').store.collect(this.column.dataIndex, false, true);\r | |
174 | Ext.form.field.ComboBox.prototype.initComponent.apply(this, arguments);\r | |
175 | }\r | |
176 | }\r | |
177 | }, {\r | |
178 | text: 'Email address',\r | |
179 | dataIndex: 'email',\r | |
180 | width: 200,\r | |
181 | groupable: false,\r | |
182 | renderer: function(v) {\r | |
183 | return '<a href="mailto:' + v + '">' + v + '</a>';\r | |
184 | },\r | |
185 | editor: {\r | |
186 | xtype: 'textfield'\r | |
187 | },\r | |
188 | filter: {\r | |
189 | \r | |
190 | }\r | |
191 | }, {\r | |
192 | text: 'Department',\r | |
193 | dataIndex: 'department',\r | |
194 | hidden: true,\r | |
195 | hideable: false,\r | |
196 | filter: {\r | |
197 | type: 'list'\r | |
198 | }\r | |
199 | }, {\r | |
200 | text: 'Absences',\r | |
201 | columns: [{\r | |
202 | text: 'Illness',\r | |
203 | dataIndex: 'sickDays',\r | |
204 | width: 100,\r | |
205 | groupable: false,\r | |
206 | summaryType: 'sum',\r | |
207 | summaryFormatter: 'number("0")',\r | |
208 | filter: {\r | |
209 | \r | |
210 | },\r | |
211 | editor: {\r | |
212 | xtype: 'numberfield',\r | |
213 | decimalPrecision: 0\r | |
214 | }\r | |
215 | }, {\r | |
216 | text: 'Holidays',\r | |
217 | dataIndex: 'holidayDays',\r | |
218 | // Size column to title text\r | |
219 | width: null,\r | |
220 | groupable: false,\r | |
221 | summaryType: 'sum',\r | |
222 | summaryFormatter: 'number("0")',\r | |
223 | filter: {\r | |
224 | \r | |
225 | },\r | |
226 | editor: {\r | |
227 | xtype: 'numberfield',\r | |
228 | decimalPrecision: 0\r | |
229 | }\r | |
230 | }, {\r | |
231 | text: 'Holiday Allowance',\r | |
232 | dataIndex: 'holidayAllowance',\r | |
233 | // Size column to title text\r | |
234 | width: null,\r | |
235 | groupable: false,\r | |
236 | filter: {\r | |
237 | \r | |
238 | },\r | |
239 | editor: {\r | |
240 | xtype: 'numberfield',\r | |
241 | decimalPrecision: 0\r | |
242 | }\r | |
243 | }]\r | |
244 | }, {\r | |
245 | text: 'Salary',\r | |
246 | width: 155,\r | |
247 | sortable: true,\r | |
248 | dataIndex: 'salary',\r | |
249 | align: 'right',\r | |
250 | formatter: 'usMoney',\r | |
251 | groupable: false,\r | |
252 | summaryType: 'average',\r | |
253 | summaryFormatter: 'usMoney',\r | |
254 | filter: {\r | |
255 | \r | |
256 | },\r | |
257 | editor: {\r | |
258 | xtype: 'numberfield',\r | |
259 | decimalPrecision: 2\r | |
260 | }\r | |
261 | }],\r | |
262 | \r | |
263 | viewConfig: {\r | |
264 | stripeRows: true\r | |
265 | },\r | |
266 | \r | |
267 | header: {\r | |
268 | itemPosition: 1, // after title before collapse tool\r | |
269 | items: [{\r | |
270 | ui: 'default-toolbar',\r | |
271 | xtype: 'button',\r | |
272 | text: 'Export to Excel',\r | |
273 | handler: 'exportToExcel'\r | |
274 | }]\r | |
275 | },\r | |
276 | \r | |
277 | plugins: [{\r | |
278 | ptype: 'gridfilters'\r | |
279 | }, {\r | |
280 | ptype: 'rowexpander',\r | |
281 | \r | |
282 | // dblclick invokes the row editor\r | |
283 | expandOnDblClick: false,\r | |
284 | rowBodyTpl: '<img src="{avatar}" height="100px" style="float:left;margin:0 10px 5px 0"><b>{name}<br></b>{dob:date}'\r | |
285 | },{\r | |
286 | ptype: 'gridexporter'\r | |
287 | }]\r | |
288 | });\r |