GridWindow.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*!
  2. * Ext JS Library 4.0
  3. * Copyright(c) 2006-2011 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.define('MyDesktop.GridWindow', {
  8. extend: 'Ext.ux.desktop.Module',
  9. requires: [
  10. 'Ext.data.ArrayStore',
  11. 'Ext.util.Format',
  12. 'Ext.grid.Panel',
  13. 'Ext.grid.RowNumberer'
  14. ],
  15. id:'grid-win',
  16. init : function(){
  17. this.launcher = {
  18. text: 'Grid Window',
  19. iconCls:'icon-grid'
  20. };
  21. },
  22. createWindow : function(){
  23. var desktop = this.app.getDesktop();
  24. var win = desktop.getWindow('grid-win');
  25. if(!win){
  26. win = desktop.createWindow({
  27. id: 'grid-win',
  28. title:'Grid Window',
  29. width:740,
  30. height:480,
  31. iconCls: 'icon-grid',
  32. animCollapse:false,
  33. constrainHeader:true,
  34. layout: 'fit',
  35. items: [
  36. {
  37. border: false,
  38. xtype: 'grid',
  39. store: new Ext.data.ArrayStore({
  40. fields: [
  41. { name: 'company' },
  42. { name: 'price', type: 'float' },
  43. { name: 'change', type: 'float' },
  44. { name: 'pctChange', type: 'float' }
  45. ],
  46. data: MyDesktop.GridWindow.getDummyData()
  47. }),
  48. columns: [
  49. new Ext.grid.RowNumberer(),
  50. {
  51. text: "Company",
  52. flex: 1,
  53. sortable: true,
  54. dataIndex: 'company'
  55. },
  56. {
  57. text: "Price",
  58. width: 70,
  59. sortable: true,
  60. renderer: Ext.util.Format.usMoney,
  61. dataIndex: 'price'
  62. },
  63. {
  64. text: "Change",
  65. width: 70,
  66. sortable: true,
  67. dataIndex: 'change'
  68. },
  69. {
  70. text: "% Change",
  71. width: 70,
  72. sortable: true,
  73. dataIndex: 'pctChange'
  74. }
  75. ]
  76. }
  77. ],
  78. tbar:[{
  79. text:'Add Something',
  80. tooltip:'Add a new row',
  81. iconCls:'add'
  82. }, '-', {
  83. text:'Options',
  84. tooltip:'Modify options',
  85. iconCls:'option'
  86. },'-',{
  87. text:'Remove Something',
  88. tooltip:'Remove the selected item',
  89. iconCls:'remove'
  90. }]
  91. });
  92. }
  93. return win;
  94. },
  95. statics: {
  96. getDummyData: function () {
  97. return [
  98. ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  99. ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  100. ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
  101. ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
  102. ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
  103. ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
  104. ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
  105. ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
  106. ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
  107. ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
  108. ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
  109. ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
  110. ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
  111. ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
  112. ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
  113. ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
  114. ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
  115. ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
  116. ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'],
  117. ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am']
  118. ];
  119. }
  120. }
  121. });