3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">
\r
9 Ext.onReady(function(){
\r
11 Ext.QuickTips.init();
\r
16 var reader = new Ext.data.ArrayReader({}, [
\r
18 {name: 'price', type: 'float'},
\r
19 {name: 'change', type: 'float'},
\r
20 {name: 'pctChange', type: 'float'},
\r
21 {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'},
\r
26 ////////////////////////////////////////////////////////////////////////////////////////
\r
28 ////////////////////////////////////////////////////////////////////////////////////////
\r
30 var expander = new Ext.ux.grid.RowExpander({
\r
31 tpl : new Ext.Template(
\r
32 '<p><b>Company:</b> {company}</p><br>',
\r
33 '<p><b>Summary:</b> {desc}</p>'
\r
37 var grid1 = new xg.GridPanel({
\r
38 store: new Ext.data.Store({
\r
42 cm: new xg.ColumnModel({
\r
49 {id:'company',header: "Company", width: 40, dataIndex: 'company'},
\r
50 {header: "Price", renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
\r
51 {header: "Change", dataIndex: 'change'},
\r
52 {header: "% Change", dataIndex: 'pctChange'},
\r
53 {header: "Last Updated", renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
\r
64 animCollapse: false,
\r
65 title: 'Expander Rows, Collapse and Force Fit',
\r
66 iconCls: 'icon-grid',
\r
67 renderTo: document.body
\r
70 ////////////////////////////////////////////////////////////////////////////////////////
\r
72 ////////////////////////////////////////////////////////////////////////////////////////
\r
73 var sm = new xg.CheckboxSelectionModel();
\r
74 var grid2 = new xg.GridPanel({
\r
75 store: new Ext.data.Store({
\r
79 cm: new xg.ColumnModel({
\r
86 {id:'company',header: "Company", width: 200, dataIndex: 'company'},
\r
87 {header: "Price", renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
\r
88 {header: "Change", dataIndex: 'change'},
\r
89 {header: "% Change", dataIndex: 'pctChange'},
\r
90 {header: "Last Updated", width: 135, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
\r
98 title:'Framed with Checkbox Selection and Horizontal Scrolling',
\r
99 iconCls:'icon-grid',
\r
100 renderTo: document.body
\r
103 ////////////////////////////////////////////////////////////////////////////////////////
\r
105 ////////////////////////////////////////////////////////////////////////////////////////
\r
106 var grid3 = new xg.GridPanel({
\r
107 store: new Ext.data.Store({
\r
111 cm: new xg.ColumnModel([
\r
112 new xg.RowNumberer(),
\r
113 {id:'company',header: "Company", width: 40, sortable: true, dataIndex: 'company'},
\r
114 {header: "Price", width: 20, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
\r
115 {header: "Change", width: 20, sortable: true, dataIndex: 'change'},
\r
116 {header: "% Change", width: 20, sortable: true, dataIndex: 'pctChange'},
\r
117 {header: "Last Updated", width: 20, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
\r
125 title:'Grid with Numbered Rows and Force Fit',
\r
126 iconCls:'icon-grid',
\r
127 renderTo: document.body
\r
130 ////////////////////////////////////////////////////////////////////////////////////////
\r
132 ////////////////////////////////////////////////////////////////////////////////////////
\r
133 var sm2 = new xg.CheckboxSelectionModel({
\r
135 // On selection change, set enabled state of the removeButton
\r
136 // which was placed into the GridPanel using the ref config
\r
137 selectionchange: function(sm) {
\r
138 if (sm.getCount()) {
\r
139 grid4.removeButton.enable();
\r
141 grid4.removeButton.disable();
\r
146 var grid4 = new xg.GridPanel({
\r
148 store: new Ext.data.Store({
\r
152 cm: new xg.ColumnModel([
\r
154 {id:'company',header: "Company", width: 40, sortable: true, dataIndex: 'company'},
\r
155 {header: "Price", width: 20, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
\r
156 {header: "Change", width: 20, sortable: true, dataIndex: 'change'},
\r
157 {header: "% Change", width: 20, sortable: true, dataIndex: 'pctChange'},
\r
158 {header: "Last Updated", width: 20, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
\r
168 buttons: [{text:'Save'},{text:'Cancel'}],
\r
169 buttonAlign:'center',
\r
173 text:'Add Something',
\r
174 tooltip:'Add a new row',
\r
178 tooltip:'Blah blah blah blaht',
\r
181 text:'Remove Something',
\r
182 tooltip:'Remove the selected item',
\r
185 // Place a reference in the GridPanel
\r
186 ref: '../removeButton',
\r
193 title:'Support for standard Panel features such as framing, buttons and toolbars',
\r
194 iconCls:'icon-grid',
\r
195 renderTo: document.body
\r
201 // Array data for the grids
\r
202 Ext.grid.dummyData = [
\r
203 ['3m Co',71.72,0.02,0.03,'9/1 12:00am', 'Manufacturing'],
\r
204 ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am', 'Manufacturing'],
\r
205 ['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am', 'Manufacturing'],
\r
206 ['American Express Company',52.55,0.01,0.02,'9/1 12:00am', 'Finance'],
\r
207 ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am', 'Services'],
\r
208 ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am', 'Services'],
\r
209 ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am', 'Manufacturing'],
\r
210 ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am', 'Services'],
\r
211 ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am', 'Finance'],
\r
212 ['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am', 'Manufacturing'],
\r
213 ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am', 'Manufacturing'],
\r
214 ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am', 'Manufacturing'],
\r
215 ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am', 'Automotive'],
\r
216 ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am', 'Computer'],
\r
217 ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am', 'Manufacturing'],
\r
218 ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am', 'Computer'],
\r
219 ['International Business Machines',81.41,0.44,0.54,'9/1 12:00am', 'Computer'],
\r
220 ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am', 'Medical'],
\r
221 ['JP Morgan & Chase & Co',45.73,0.07,0.15,'9/1 12:00am', 'Finance'],
\r
222 ['McDonald\'s Corporation',36.76,0.86,2.40,'9/1 12:00am', 'Food'],
\r
223 ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am', 'Medical'],
\r
224 ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am', 'Computer'],
\r
225 ['Pfizer Inc',27.96,0.4,1.45,'9/1 12:00am', 'Services', 'Medical'],
\r
226 ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am', 'Food'],
\r
227 ['The Home Depot, Inc.',34.64,0.35,1.02,'9/1 12:00am', 'Retail'],
\r
228 ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am', 'Manufacturing'],
\r
229 ['United Technologies Corporation',63.26,0.55,0.88,'9/1 12:00am', 'Computer'],
\r
230 ['Verizon Communications',35.57,0.39,1.11,'9/1 12:00am', 'Services'],
\r
231 ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am', 'Retail'],
\r
232 ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am', 'Services']
\r
235 // add in some dummy descriptions
\r
236 for(var i = 0; i < Ext.grid.dummyData.length; i++){
\r
237 Ext.grid.dummyData[i].push('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit.');
\r