Web Interface For Lite Argus Control modules
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.

130 lines
4.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.onReady(function() {
  8. var structure = {
  9. Asia: ['Beijing', 'Tokyo'],
  10. Europe: ['Berlin', 'London', 'Paris']
  11. },
  12. products = ['ProductX', 'ProductY'],
  13. fields = [],
  14. columns = [],
  15. data = [],
  16. continentGroupRow = [],
  17. cityGroupRow = [];
  18. /*
  19. * Example method that generates:
  20. * 1) The column configuration for the grid
  21. * 2) The column grouping configuration
  22. * 3) The data for the store
  23. * 4) The fields for the store
  24. */
  25. function generateConfig(){
  26. var arr,
  27. numProducts = products.length;
  28. Ext.iterate(structure, function(continent, cities){
  29. continentGroupRow.push({
  30. header: continent,
  31. align: 'center',
  32. colspan: cities.length * numProducts
  33. });
  34. Ext.each(cities, function(city){
  35. cityGroupRow.push({
  36. header: city,
  37. colspan: numProducts,
  38. align: 'center'
  39. });
  40. Ext.each(products, function(product){
  41. fields.push({
  42. type: 'int',
  43. name: city + product
  44. });
  45. columns.push({
  46. dataIndex: city + product,
  47. header: product,
  48. renderer: Ext.util.Format.usMoney
  49. });
  50. });
  51. arr = [];
  52. for(var i = 0; i < 20; ++i){
  53. arr.push((Math.floor(Math.random()*11) + 1) * 100000);
  54. }
  55. data.push(arr);
  56. });
  57. })
  58. }
  59. // Run method to generate columns, fields, row grouping
  60. generateConfig();
  61. /*
  62. * continentGroupRow at this point is:
  63. * [
  64. * {header: 'Asia', colspan: 4, align: 'center'},
  65. * {header: 'Europe', colspan: 6, align: 'center'}
  66. * ]
  67. *
  68. * cityGroupRow at this point is:
  69. * [
  70. * {header: 'Beijing', colspan: 2, align: 'center'},
  71. * {header: 'Tokyo', colspan: 2, align: 'center'},
  72. * {header: 'Berlin', colspan: 2, align: 'center'},
  73. * {header: 'London', colspan: 2, align: 'center'},
  74. * {header: 'Paris', colspan: 2, align: 'center'}
  75. * ]
  76. */
  77. var group = new Ext.ux.grid.ColumnHeaderGroup({
  78. rows: [continentGroupRow, cityGroupRow]
  79. });
  80. /*
  81. * fields at this point is:
  82. * [
  83. * {type: 'int', name: 'BeijingProductX'},
  84. * {type: 'int', name: 'BeijingProductY'},
  85. * {type: 'int', name: 'TokyoProductX'},
  86. * {type: 'int', name: 'TokyoProductY'},
  87. * {type: 'int', name: 'BerlinProductX'},
  88. * {type: 'int', name: 'BerlinProductY'},
  89. * {type: 'int', name: 'LondonProductX'},
  90. * {type: 'int', name: 'LondonProductY'},
  91. * {type: 'int', name: 'ParisProductX'},
  92. * {type: 'int', name: 'ParisProductY'}
  93. * ]
  94. *
  95. * columns at this point is:
  96. * [
  97. * {dataIndex: 'BeijingProductX', header: 'ProductX'},
  98. * {dataIndex: 'BeijingProductY', header: 'ProductY'},
  99. * {dataIndex: 'TokyoProductX', header: 'ProductX'},
  100. * {dataIndex: 'TokyoProductY', header: 'ProductY'},
  101. * {dataIndex: 'BerlinProductX', header: 'ProductX'},
  102. * {dataIndex: 'BerlinProductY', header: 'ProductY'},
  103. * {dataIndex: 'LondonProductX', header: 'ProductX'},
  104. * {dataIndex: 'LondonProductY', header: 'ProductY'},
  105. * {dataIndex: 'ParisProductX', header: 'ProductX'},
  106. * {dataIndex: 'ParisProductY', header: 'ProductY'}
  107. * ]
  108. */
  109. var grid = new Ext.grid.GridPanel({
  110. renderTo: 'column-group-grid',
  111. title: 'Sales By Location',
  112. width: 1000,
  113. height: 400,
  114. store: new Ext.data.ArrayStore({
  115. fields: fields,
  116. data: data
  117. }),
  118. columns: columns,
  119. viewConfig: {
  120. forceFit: true
  121. },
  122. plugins: group
  123. });
  124. });