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.

165 lines
7.0 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. Ext.QuickTips.init();
  9. var xg = Ext.grid;
  10. var reader = new Ext.data.JsonReader({
  11. idProperty: 'taskId',
  12. fields: [
  13. {name: 'projectId', type: 'int'},
  14. {name: 'project', type: 'string'},
  15. {name: 'taskId', type: 'int'},
  16. {name: 'description', type: 'string'},
  17. {name: 'estimate', type: 'float'},
  18. {name: 'rate', type: 'float'},
  19. {name: 'cost', type: 'float'},
  20. {name: 'due', type: 'date', dateFormat:'m/d/Y'}
  21. ]
  22. });
  23. // define a custom summary function
  24. Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
  25. return v + (record.data.estimate * record.data.rate);
  26. };
  27. // utilize custom extension for Group Summary
  28. var summary = new Ext.ux.grid.GroupSummary();
  29. var grid = new xg.EditorGridPanel({
  30. ds: new Ext.data.GroupingStore({
  31. reader: reader,
  32. // use local data
  33. data: app.grid.dummyData,
  34. sortInfo: {field: 'due', direction: 'ASC'},
  35. groupField: 'project'
  36. }),
  37. columns: [
  38. {
  39. id: 'description',
  40. header: 'Task',
  41. width: 80,
  42. sortable: true,
  43. dataIndex: 'description',
  44. summaryType: 'count',
  45. hideable: false,
  46. summaryRenderer: function(v, params, data){
  47. return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
  48. },
  49. editor: new Ext.form.TextField({
  50. allowBlank: false
  51. })
  52. },{
  53. header: 'Project',
  54. width: 20,
  55. sortable: true,
  56. dataIndex: 'project'
  57. },{
  58. header: 'Due Date',
  59. width: 25,
  60. sortable: true,
  61. dataIndex: 'due',
  62. summaryType: 'max',
  63. renderer: Ext.util.Format.dateRenderer('m/d/Y'),
  64. editor: new Ext.form.DateField({
  65. format: 'm/d/Y'
  66. })
  67. },{
  68. header: 'Estimate',
  69. width: 20,
  70. sortable: true,
  71. dataIndex: 'estimate',
  72. summaryType: 'sum',
  73. renderer : function(v){
  74. return v +' hours';
  75. },
  76. editor: new Ext.form.NumberField({
  77. allowBlank: false,
  78. allowNegative: false,
  79. style: 'text-align:left'
  80. })
  81. },{
  82. header: 'Rate',
  83. width: 20,
  84. sortable: true,
  85. renderer: Ext.util.Format.usMoney,
  86. dataIndex: 'rate',
  87. summaryType: 'average',
  88. editor: new Ext.form.NumberField({
  89. allowBlank: false,
  90. allowNegative: false,
  91. style: 'text-align:left'
  92. })
  93. },{
  94. id: 'cost',
  95. header: 'Cost',
  96. width: 20,
  97. sortable: false,
  98. groupable: false,
  99. renderer: function(v, params, record){
  100. return Ext.util.Format.usMoney(record.data.estimate * record.data.rate);
  101. },
  102. dataIndex: 'cost',
  103. summaryType: 'totalCost',
  104. summaryRenderer: Ext.util.Format.usMoney
  105. }
  106. ],
  107. view: new Ext.grid.GroupingView({
  108. forceFit: true,
  109. showGroupName: false,
  110. enableNoGroups: false,
  111. enableGroupingMenu: false,
  112. hideGroupedColumn: true
  113. }),
  114. plugins: summary,
  115. tbar : [{
  116. text: 'Toggle',
  117. tooltip: 'Toggle the visibility of summary row',
  118. handler: function(){summary.toggleSummaries();}
  119. }],
  120. frame: true,
  121. width: 800,
  122. height: 450,
  123. clicksToEdit: 1,
  124. collapsible: true,
  125. animCollapse: false,
  126. trackMouseOver: false,
  127. //enableColumnMove: false,
  128. title: 'Sponsored Projects',
  129. iconCls: 'icon-grid',
  130. renderTo: document.body
  131. });
  132. });
  133. // set up namespace for application
  134. Ext.ns('app.grid');
  135. // store dummy data in the app namespace
  136. app.grid.dummyData = [
  137. {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 112, description: 'Integrate 2.0 Forms with 2.0 Layouts', estimate: 6, rate: 150, due:'06/24/2007'},
  138. {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 113, description: 'Implement AnchorLayout', estimate: 4, rate: 150, due:'06/25/2007'},
  139. {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 114, description: 'Add support for multiple types of anchors', estimate: 4, rate: 150, due:'06/27/2007'},
  140. {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 115, description: 'Testing and debugging', estimate: 8, rate: 0, due:'06/29/2007'},
  141. {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 101, description: 'Add required rendering "hooks" to GridView', estimate: 6, rate: 100, due:'07/01/2007'},
  142. {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 102, description: 'Extend GridView and override rendering functions', estimate: 6, rate: 100, due:'07/03/2007'},
  143. {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 103, description: 'Extend Store with grouping functionality', estimate: 4, rate: 100, due:'07/04/2007'},
  144. {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 121, description: 'Default CSS Styling', estimate: 2, rate: 100, due:'07/05/2007'},
  145. {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 104, description: 'Testing and debugging', estimate: 6, rate: 100, due:'07/06/2007'},
  146. {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 105, description: 'Ext Grid plugin integration', estimate: 4, rate: 125, due:'07/01/2007'},
  147. {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 106, description: 'Summary creation during rendering phase', estimate: 4, rate: 125, due:'07/02/2007'},
  148. {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 107, description: 'Dynamic summary updates in editor grids', estimate: 6, rate: 125, due:'07/05/2007'},
  149. {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 108, description: 'Remote summary integration', estimate: 4, rate: 125, due:'07/05/2007'},
  150. {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 109, description: 'Summary renderers and calculators', estimate: 4, rate: 125, due:'07/06/2007'},
  151. {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 110, description: 'Integrate summaries with GroupingView', estimate: 10, rate: 125, due:'07/11/2007'},
  152. {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 111, description: 'Testing and debugging', estimate: 8, rate: 125, due:'07/15/2007'}
  153. ];