You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

249 lines
10 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.onReady(function(){
  16. Ext.QuickTips.init();
  17. var xg = Ext.grid;
  18. // shared reader
  19. var reader = new Ext.data.ArrayReader({}, [
  20. {name: 'company'},
  21. {name: 'price', type: 'float'},
  22. {name: 'change', type: 'float'},
  23. {name: 'pctChange', type: 'float'},
  24. {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'},
  25. {name: 'industry'},
  26. {name: 'desc'}
  27. ]);
  28. ////////////////////////////////////////////////////////////////////////////////////////
  29. // Grid 1
  30. ////////////////////////////////////////////////////////////////////////////////////////
  31. // row expander
  32. var expander = new Ext.ux.grid.RowExpander({
  33. tpl : new Ext.Template(
  34. '<p><b>Company:</b> {company}</p><br>',
  35. '<p><b>Summary:</b> {desc}</p>'
  36. )
  37. });
  38. var grid1 = new xg.GridPanel({
  39. store: new Ext.data.Store({
  40. reader: reader,
  41. data: xg.dummyData
  42. }),
  43. cm: new xg.ColumnModel({
  44. defaults: {
  45. width: 20,
  46. sortable: true
  47. },
  48. columns: [
  49. expander,
  50. {id:'company',header: "Company", width: 40, dataIndex: 'company'},
  51. {header: "Price", renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  52. {header: "Change", dataIndex: 'change'},
  53. {header: "% Change", dataIndex: 'pctChange'},
  54. {header: "Last Updated", renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
  55. ]
  56. }),
  57. viewConfig: {
  58. forceFit:true
  59. },
  60. width: 600,
  61. height: 300,
  62. plugins: expander,
  63. collapsible: true,
  64. animCollapse: false,
  65. title: 'Expander Rows, Collapse and Force Fit',
  66. iconCls: 'icon-grid',
  67. renderTo: document.body
  68. });
  69. ////////////////////////////////////////////////////////////////////////////////////////
  70. // Grid 2
  71. ////////////////////////////////////////////////////////////////////////////////////////
  72. var sm = new xg.CheckboxSelectionModel();
  73. var grid2 = new xg.GridPanel({
  74. store: new Ext.data.Store({
  75. reader: reader,
  76. data: xg.dummyData
  77. }),
  78. cm: new xg.ColumnModel({
  79. defaults: {
  80. width: 120,
  81. sortable: true
  82. },
  83. columns: [
  84. sm,
  85. {id:'company',header: "Company", width: 200, dataIndex: 'company'},
  86. {header: "Price", renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  87. {header: "Change", dataIndex: 'change'},
  88. {header: "% Change", dataIndex: 'pctChange'},
  89. {header: "Last Updated", width: 135, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
  90. ]
  91. }),
  92. sm: sm,
  93. columnLines: true,
  94. width:600,
  95. height:300,
  96. frame:true,
  97. title:'Framed with Checkbox Selection and Horizontal Scrolling',
  98. iconCls:'icon-grid',
  99. renderTo: document.body
  100. });
  101. ////////////////////////////////////////////////////////////////////////////////////////
  102. // Grid 3
  103. ////////////////////////////////////////////////////////////////////////////////////////
  104. var grid3 = new xg.GridPanel({
  105. store: new Ext.data.Store({
  106. reader: reader,
  107. data: xg.dummyData
  108. }),
  109. cm: new xg.ColumnModel([
  110. new xg.RowNumberer(),
  111. {id:'company',header: "Company", width: 40, sortable: true, dataIndex: 'company'},
  112. {header: "Price", width: 20, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  113. {header: "Change", width: 20, sortable: true, dataIndex: 'change'},
  114. {header: "% Change", width: 20, sortable: true, dataIndex: 'pctChange'},
  115. {header: "Last Updated", width: 20, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
  116. ]),
  117. viewConfig: {
  118. forceFit:true
  119. },
  120. columnLines: true,
  121. width:600,
  122. height:300,
  123. title:'Grid with Numbered Rows and Force Fit',
  124. iconCls:'icon-grid',
  125. renderTo: document.body
  126. });
  127. ////////////////////////////////////////////////////////////////////////////////////////
  128. // Grid 4
  129. ////////////////////////////////////////////////////////////////////////////////////////
  130. var sm2 = new xg.CheckboxSelectionModel({
  131. listeners: {
  132. // On selection change, set enabled state of the removeButton
  133. // which was placed into the GridPanel using the ref config
  134. selectionchange: function(sm) {
  135. if (sm.getCount()) {
  136. grid4.removeButton.enable();
  137. } else {
  138. grid4.removeButton.disable();
  139. }
  140. }
  141. }
  142. });
  143. var grid4 = new xg.GridPanel({
  144. id:'button-grid',
  145. store: new Ext.data.Store({
  146. reader: reader,
  147. data: xg.dummyData
  148. }),
  149. cm: new xg.ColumnModel([
  150. sm2,
  151. {id:'company',header: "Company", width: 40, sortable: true, dataIndex: 'company'},
  152. {header: "Price", width: 20, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  153. {header: "Change", width: 20, sortable: true, dataIndex: 'change'},
  154. {header: "% Change", width: 20, sortable: true, dataIndex: 'pctChange'},
  155. {header: "Last Updated", width: 20, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
  156. ]),
  157. sm: sm2,
  158. viewConfig: {
  159. forceFit:true
  160. },
  161. columnLines: true,
  162. // inline buttons
  163. buttons: [{text:'Save'},{text:'Cancel'}],
  164. buttonAlign:'center',
  165. // inline toolbars
  166. tbar:[{
  167. text:'Add Something',
  168. tooltip:'Add a new row',
  169. iconCls:'add'
  170. }, '-', {
  171. text:'Options',
  172. tooltip:'Blah blah blah blaht',
  173. iconCls:'option'
  174. },'-',{
  175. text:'Remove Something',
  176. tooltip:'Remove the selected item',
  177. iconCls:'remove',
  178. // Place a reference in the GridPanel
  179. ref: '../removeButton',
  180. disabled: true
  181. }],
  182. width:600,
  183. height:300,
  184. frame:true,
  185. title:'Support for standard Panel features such as framing, buttons and toolbars',
  186. iconCls:'icon-grid',
  187. renderTo: document.body
  188. });
  189. });
  190. // Array data for the grids
  191. Ext.grid.dummyData = [
  192. ['3m Co',71.72,0.02,0.03,'9/1 12:00am', 'Manufacturing'],
  193. ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am', 'Manufacturing'],
  194. ['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am', 'Manufacturing'],
  195. ['American Express Company',52.55,0.01,0.02,'9/1 12:00am', 'Finance'],
  196. ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am', 'Services'],
  197. ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am', 'Services'],
  198. ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am', 'Manufacturing'],
  199. ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am', 'Services'],
  200. ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am', 'Finance'],
  201. ['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am', 'Manufacturing'],
  202. ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am', 'Manufacturing'],
  203. ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am', 'Manufacturing'],
  204. ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am', 'Automotive'],
  205. ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am', 'Computer'],
  206. ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am', 'Manufacturing'],
  207. ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am', 'Computer'],
  208. ['International Business Machines',81.41,0.44,0.54,'9/1 12:00am', 'Computer'],
  209. ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am', 'Medical'],
  210. ['JP Morgan & Chase & Co',45.73,0.07,0.15,'9/1 12:00am', 'Finance'],
  211. ['McDonald\'s Corporation',36.76,0.86,2.40,'9/1 12:00am', 'Food'],
  212. ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am', 'Medical'],
  213. ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am', 'Computer'],
  214. ['Pfizer Inc',27.96,0.4,1.45,'9/1 12:00am', 'Services', 'Medical'],
  215. ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am', 'Food'],
  216. ['The Home Depot, Inc.',34.64,0.35,1.02,'9/1 12:00am', 'Retail'],
  217. ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am', 'Manufacturing'],
  218. ['United Technologies Corporation',63.26,0.55,0.88,'9/1 12:00am', 'Computer'],
  219. ['Verizon Communications',35.57,0.39,1.11,'9/1 12:00am', 'Services'],
  220. ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am', 'Retail'],
  221. ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am', 'Services']
  222. ];
  223. // add in some dummy descriptions
  224. for(var i = 0; i < Ext.grid.dummyData.length; i++){
  225. 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.');
  226. }