Upgrade to ExtJS 3.1.0 - Released 12/16/2009
[extjs.git] / examples / test-case-2b / resources / grid-configs.js
1 /*!
2  * Ext JS Library 3.1.0
3  * Copyright(c) 2006-2009 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /*!
8  * Ext JS Library 3.1.0
9  * Copyright(c) 2006-2009 Ext JS, LLC
10  * licensing@extjs.com
11  * http://www.extjs.com/license
12  */
13 /*!
14  * Ext JS Library 3.1.0
15  * Copyright(c) 2006-2009 Ext JS, LLC
16  * licensing@extjs.com
17  * http://www.extjs.com/license
18  */
19 /*!
20  * Ext JS Library 3.1.0
21  * Copyright(c) 2006-2009 Ext JS, LLC
22  * licensing@extjs.com
23  * http://www.extjs.com/license
24  */
25 /*!
26  * Ext JS Library 3.1.0
27  * Copyright(c) 2006-2009 Ext JS, LLC
28  * licensing@extjs.com
29  * http://www.extjs.com/license
30  */
31 /*!
32  * Ext JS Library 3.1.0
33  * Copyright(c) 2006-2009 Ext JS, LLC
34  * licensing@extjs.com
35  * http://www.extjs.com/license
36  */
37 /*!
38  * Ext JS Library 3.1.0
39  * Copyright(c) 2006-2009 Ext JS, LLC
40  * licensing@extjs.com
41  * http://www.extjs.com/license
42  */
43 /*!
44  * Ext JS Library 3.1.0
45  * Copyright(c) 2006-2009 Ext JS, LLC
46  * licensing@extjs.com
47  * http://www.extjs.com/license
48  */
49 /*!
50  * Ext JS Library 3.1.0
51  * Copyright(c) 2006-2009 Ext JS, LLC
52  * licensing@extjs.com
53  * http://www.extjs.com/license
54  */
55 /*!
56  * Ext JS Library 3.1.0
57  * Copyright(c) 2006-2009 Ext JS, LLC
58  * licensing@extjs.com
59  * http://www.extjs.com/license
60  */
61 /*!
62  * Ext JS Library 3.1.0
63  * Copyright(c) 2006-2009 Ext JS, LLC
64  * licensing@extjs.com
65  * http://www.extjs.com/license
66  */
67 /*!
68  * Ext JS Library 3.1.0
69  * Copyright(c) 2006-2009 Ext JS, LLC
70  * licensing@extjs.com
71  * http://www.extjs.com/license
72  */
73 /*!
74  * Ext JS Library 3.1.0
75  * Copyright(c) 2006-2009 Ext JS, LLC
76  * licensing@extjs.com
77  * http://www.extjs.com/license
78  */
79 /*!
80  * Ext JS Library 3.1.0
81  * Copyright(c) 2006-2009 Ext JS, LLC
82  * licensing@extjs.com
83  * http://www.extjs.com/license
84  */
85 /*!
86  * Ext JS Library 3.1.0
87  * Copyright(c) 2006-2009 Ext JS, LLC
88  * licensing@extjs.com
89  * http://www.extjs.com/license
90  */
91 /*!
92  * Ext JS Library 3.1.0
93  * Copyright(c) 2006-2009 Ext JS, LLC
94  * licensing@extjs.com
95  * http://www.extjs.com/license
96  */
97 /*!
98  * Ext JS Library 3.1.0
99  * Copyright(c) 2006-2009 Ext JS, LLC
100  * licensing@extjs.com
101  * http://www.extjs.com/license
102  */
103 /*!
104  * Ext JS Library 3.1.0
105  * Copyright(c) 2006-2009 Ext JS, LLC
106  * licensing@extjs.com
107  * http://www.extjs.com/license
108  */
109 /*!
110  * Ext JS Library 3.1.0
111  * Copyright(c) 2006-2009 Ext JS, LLC
112  * licensing@extjs.com
113  * http://www.extjs.com/license
114  */
115 /*!
116  * Ext JS Library 3.1.0
117  * Copyright(c) 2006-2009 Ext JS, LLC
118  * licensing@extjs.com
119  * http://www.extjs.com/license
120  */
121 /*!
122  * Ext JS Library 3.1.0
123  * Copyright(c) 2006-2009 Ext JS, LLC
124  * licensing@extjs.com
125  * http://www.extjs.com/license
126  */
127 /*!
128  * Ext JS Library 3.1.0
129  * Copyright(c) 2006-2009 Ext JS, LLC
130  * licensing@extjs.com
131  * http://www.extjs.com/license
132  */
133 /*!
134  * Ext JS Library 3.1.0
135  * Copyright(c) 2006-2009 Ext JS, LLC
136  * licensing@extjs.com
137  * http://www.extjs.com/license
138  */
139 /*!
140  * Ext JS Library 3.1.0
141  * Copyright(c) 2006-2009 Ext JS, LLC
142  * licensing@extjs.com
143  * http://www.extjs.com/license
144  */
145 /*!
146  * Ext JS Library 3.1.0
147  * Copyright(c) 2006-2009 Ext JS, LLC
148  * licensing@extjs.com
149  * http://www.extjs.com/license
150  */
151 /*!
152  * Ext JS Library 3.1.0
153  * Copyright(c) 2006-2009 Ext JS, LLC
154  * licensing@extjs.com
155  * http://www.extjs.com/license
156  */
157 /*!
158  * Ext JS Library 3.1.0
159  * Copyright(c) 2006-2009 Ext JS, LLC
160  * licensing@extjs.com
161  * http://www.extjs.com/license
162  */
163 /*!
164  * Ext JS Library 3.1.0
165  * Copyright(c) 2006-2009 Ext JS, LLC
166  * licensing@extjs.com
167  * http://www.extjs.com/license
168  */
169 /*!
170  * Ext JS Library 3.1.0
171  * Copyright(c) 2006-2009 Ext JS, LLC
172  * licensing@extjs.com
173  * http://www.extjs.com/license
174  */
175 /*!
176  * Ext JS Library 3.1.0
177  * Copyright(c) 2006-2009 Ext JS, LLC
178  * licensing@extjs.com
179  * http://www.extjs.com/license
180  */
181 /*!
182  * Ext JS Library 3.1.0
183  * Copyright(c) 2006-2009 Ext JS, LLC
184  * licensing@extjs.com
185  * http://www.extjs.com/license
186  */
187 /*!
188  * Ext JS Library 3.1.0
189  * Copyright(c) 2006-2009 Ext JS, LLC
190  * licensing@extjs.com
191  * http://www.extjs.com/license
192  */
193 /*!
194  * Ext JS Library 3.1.0
195  * Copyright(c) 2006-2009 Ext JS, LLC
196  * licensing@extjs.com
197  * http://www.extjs.com/license
198  */
199 /*!
200  * Ext JS Library 3.1.0
201  * Copyright(c) 2006-2009 Ext JS, LLC
202  * licensing@extjs.com
203  * http://www.extjs.com/license
204  */
205 /*!
206  * Ext JS Library 3.1.0
207  * Copyright(c) 2006-2009 Ext JS, LLC
208  * licensing@extjs.com
209  * http://www.extjs.com/license
210  */
211 /*!
212  * Ext JS Library 3.1.0
213  * Copyright(c) 2006-2009 Ext JS, LLC
214  * licensing@extjs.com
215  * http://www.extjs.com/license
216  */
217 /*!
218  * Ext JS Library 3.1.0
219  * Copyright(c) 2006-2009 Ext JS, LLC
220  * licensing@extjs.com
221  * http://www.extjs.com/license
222  */
223 /*!
224  * Ext JS Library 3.1.0
225  * Copyright(c) 2006-2009 Ext JS, LLC
226  * licensing@extjs.com
227  * http://www.extjs.com/license
228  */
229 /*!
230  * Ext JS Library 3.1.0
231  * Copyright(c) 2006-2009 Ext JS, LLC
232  * licensing@extjs.com
233  * http://www.extjs.com/license
234  */
235 /*!
236  * Ext JS Library 3.1.0
237  * Copyright(c) 2006-2009 Ext JS, LLC
238  * licensing@extjs.com
239  * http://www.extjs.com/license
240  */
241 /*!
242  * Ext JS Library 3.1.0
243  * Copyright(c) 2006-2009 Ext JS, LLC
244  * licensing@extjs.com
245  * http://www.extjs.com/license
246  */
247 /*!
248  * Ext JS Library 3.1.0
249  * Copyright(c) 2006-2009 Ext JS, LLC
250  * licensing@extjs.com
251  * http://www.extjs.com/license
252  */
253 /*!
254  * Ext JS Library 3.1.0
255  * Copyright(c) 2006-2009 Ext JS, LLC
256  * licensing@extjs.com
257  * http://www.extjs.com/license
258  */
259
260 // Data for the grid config.
261
262 var myData = [
263     ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
264     ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
265     ['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am'],
266     ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
267     ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
268     ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
269     ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
270     ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
271     ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
272     ['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am'],
273     ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
274     ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
275     ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
276     ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
277     ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
278     ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
279     ['International Business Machines',81.41,0.44,0.54,'9/1 12:00am'],
280     ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
281     ['JP Morgan & Chase & Co',45.73,0.07,0.15,'9/1 12:00am'],
282     ['McDonald\'s Corporation',36.76,0.86,2.40,'9/1 12:00am'],
283     ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
284     ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
285     ['Pfizer Inc',27.96,0.4,1.45,'9/1 12:00am'],
286     ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
287     ['The Home Depot, Inc.',34.64,0.35,1.02,'9/1 12:00am'],
288     ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
289     ['United Technologies Corporation',63.26,0.55,0.88,'9/1 12:00am'],
290     ['Verizon Communications',35.57,0.39,1.11,'9/1 12:00am'],            
291     ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
292 ];
293
294 /**
295  * Custom function used for column renderer
296  * @param {Object} val
297  */
298 function change(val){
299
300     if(val > 0){
301         return '<span style="color:green;">' + val + '</span>';
302     }else if(val < 0){
303         return '<span style="color:red;">' + val + '</span>';
304     }
305     return val;
306 }
307
308 /**
309  * Custom function used for column renderer
310  * @param {Object} val
311  */
312 function pctChange(val){
313
314     if(val > 0){
315         return '<span style="color:green;">' + val + '%</span>';
316     }else if(val < 0){
317         return '<span style="color:red;">' + val + '%</span>';
318     }
319     return val;
320 }
321
322 // create the data store
323 var store = new Ext.data.ArrayStore({
324
325     fields: [
326        {name: 'company'},
327        {name: 'price', type: 'float'},
328        {name: 'change', type: 'float'},
329        {name: 'pctChange', type: 'float'},
330        {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
331     ]
332 });
333
334 // manually load local data
335 store.loadData(myData);
336
337 // There is only 1 grid config.
338
339 var gridConfigs = [{
340    //
341    // -- grid config 1
342    //
343    xtype: 'grid',
344    baseCls: 'x-bubble',
345    frame: true,
346    border: false,
347
348    height: 440,
349    width: 680,
350    monitorWindowResize: false,
351
352    store: store,
353
354    columns: [
355       {id:'company',header: 'Company', width: 160, sortable: true, dataIndex: 'company'},
356       {header: 'Price', width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
357       {header: 'Change', width: 75, sortable: true, renderer: change, dataIndex: 'change'},
358       {header: '% Change', width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange'},
359       {header: 'Last Updated', width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
360    ],
361    stripeRows: true,
362    autoExpandColumn: 'company'
363 },{
364    //
365    // -- grid config 2
366    //
367 }];
368