]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/classic/grid/live-search-grid.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / classic / grid / live-search-grid.js
CommitLineData
6527f429
DM
1Ext.require([\r
2 'Ext.grid.*',\r
3 'Ext.data.*',\r
4 'Ext.util.*',\r
5 'Ext.tip.QuickTipManager',\r
6 'Ext.ux.LiveSearchGridPanel'\r
7]);\r
8\r
9Ext.onReady(function() { \r
10 Ext.QuickTips.init();\r
11 \r
12 // sample static data for the store\r
13 var myData = [\r
14 ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],\r
15 ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],\r
16 ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'],\r
17 ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'],\r
18 ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],\r
19 ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],\r
20 ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],\r
21 ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],\r
22 ['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'],\r
23 ['E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'],\r
24 ['Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am'],\r
25 ['General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'],\r
26 ['General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'],\r
27 ['Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'],\r
28 ['Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'],\r
29 ['Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'],\r
30 ['International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'],\r
31 ['Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'],\r
32 ['JP Morgan & Chase & Co', 45.73, 0.07, 0.15, '9/1 12:00am'],\r
33 ['McDonald\'s Corporation', 36.76, 0.86, 2.40, '9/1 12:00am'],\r
34 ['Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'],\r
35 ['Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'],\r
36 ['Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'],\r
37 ['The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'],\r
38 ['The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'],\r
39 ['The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'],\r
40 ['United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'],\r
41 ['Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'],\r
42 ['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am']\r
43 ];\r
44\r
45 /**\r
46 * Custom function used for column renderer\r
47 * @param {Object} val\r
48 */\r
49 function change(val){\r
50 if(val > 0){\r
51 return '<span style="color:green;">' + val + '</span>';\r
52 }else if(val < 0){\r
53 return '<span style="color:red;">' + val + '</span>';\r
54 }\r
55 return val;\r
56 }\r
57\r
58 /**\r
59 * Custom function used for column renderer\r
60 * @param {Object} val\r
61 */\r
62 function pctChange(val){\r
63 if(val > 0){\r
64 return '<span style="color:green;">' + val + '%</span>';\r
65 }else if(val < 0){\r
66 return '<span style="color:red;">' + val + '%</span>';\r
67 }\r
68 return val;\r
69 } \r
70 \r
71 \r
72 // create the data store\r
73 var store = Ext.create('Ext.data.ArrayStore', {\r
74 fields: [\r
75 {name: 'company'},\r
76 {name: 'price', type: 'float'},\r
77 {name: 'change', type: 'float'},\r
78 {name: 'pctChange', type: 'float'},\r
79 {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}\r
80 ],\r
81 data: myData\r
82 });\r
83 \r
84 // create the Grid, see Ext.\r
85 Ext.create('Ext.ux.LiveSearchGridPanel', {\r
86 store: store,\r
87 columnLines: true,\r
88 columns: [\r
89 {\r
90 text : 'Company',\r
91 flex : 1,\r
92 sortable : false,\r
93 dataIndex: 'company'\r
94 },\r
95 {\r
96 text : 'Price',\r
97 width : 75,\r
98 sortable : true,\r
99 formatter: 'usMoney',\r
100 dataIndex: 'price'\r
101 },\r
102 {\r
103 text : 'Change',\r
104 width : 86,\r
105 sortable : true,\r
106 dataIndex: 'change',\r
107 renderer: change\r
108 },\r
109 {\r
110 text : '% Change',\r
111 width : 110,\r
112 sortable : true,\r
113 dataIndex: 'pctChange',\r
114 renderer: pctChange\r
115 },\r
116 {\r
117 text : 'Last Updated',\r
118 width : 126,\r
119 sortable : true,\r
120 formatter: 'date',\r
121 dataIndex: 'lastChange'\r
122 }\r
123 ],\r
124 height: 350,\r
125 width: Ext.themeName === 'neptune-touch' || Ext.themeName === 'crisp' ? 700 : 670,\r
126 title: 'Live Search Grid',\r
127 renderTo: 'grid-example',\r
128 viewConfig: {\r
129 stripeRows: true\r
130 }\r
131 });\r
132});\r