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
5.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. 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. // additional configuration for remote
  23. root:'data',
  24. remoteGroup:true,
  25. remoteSort: true
  26. });
  27. // define a custom summary function
  28. Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
  29. return v + (record.data.estimate * record.data.rate);
  30. };
  31. // utilize custom extension for Hybrid Summary
  32. var summary = new Ext.ux.grid.HybridSummary();
  33. var grid = new xg.EditorGridPanel({
  34. ds: new Ext.data.GroupingStore({
  35. reader: reader,
  36. // use remote data
  37. proxy : new Ext.data.HttpProxy({
  38. url: 'totals-hybrid.json',
  39. method: 'GET'
  40. }),
  41. sortInfo: {field: 'due', direction: 'ASC'},
  42. groupField: 'project'
  43. }),
  44. columns: [
  45. {
  46. id: 'description',
  47. header: 'Task',
  48. width: 80,
  49. sortable: true,
  50. dataIndex: 'description',
  51. summaryType: 'count',
  52. hideable: false,
  53. summaryRenderer: function(v, params, data){
  54. return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
  55. },
  56. editor: new Ext.form.TextField({
  57. allowBlank: false
  58. })
  59. },{
  60. header: 'Project',
  61. width: 20,
  62. sortable: true,
  63. dataIndex: 'project'
  64. },{
  65. header: 'Due Date',
  66. width: 25,
  67. sortable: true,
  68. dataIndex: 'due',
  69. summaryType:'max',
  70. renderer: Ext.util.Format.dateRenderer('m/d/Y'),
  71. editor: new Ext.form.DateField({
  72. format: 'm/d/Y'
  73. })
  74. },{
  75. header: 'Estimate',
  76. width: 20,
  77. sortable: true,
  78. dataIndex: 'estimate',
  79. summaryType:'sum',
  80. renderer : function(v){
  81. return v +' hours';
  82. },
  83. editor: new Ext.form.NumberField({
  84. allowBlank: false,
  85. allowNegative: false,
  86. style: 'text-align:left'
  87. })
  88. },{
  89. header: 'Rate',
  90. width: 20,
  91. sortable: true,
  92. renderer: Ext.util.Format.usMoney,
  93. dataIndex: 'rate',
  94. summaryType:'average',
  95. editor: new Ext.form.NumberField({
  96. allowBlank: false,
  97. allowNegative: false,
  98. style: 'text-align:left'
  99. })
  100. },{
  101. id: 'cost',
  102. header: 'Cost',
  103. width: 20,
  104. sortable: false,
  105. groupable: false,
  106. renderer: function(v, params, record){
  107. return Ext.util.Format.usMoney(record.data.estimate * record.data.rate);
  108. },
  109. dataIndex: 'cost',
  110. summaryType: 'totalCost',
  111. summaryRenderer: Ext.util.Format.usMoney
  112. }
  113. ],
  114. view: new Ext.grid.GroupingView({
  115. forceFit:true,
  116. showGroupName: false,
  117. enableNoGroups:false,
  118. enableGroupingMenu:false,
  119. hideGroupedColumn: true
  120. }),
  121. plugins: summary,
  122. tbar : [{
  123. text: 'Toggle',
  124. tooltip: 'Toggle the visibility of summary row',
  125. handler: function(){summary.toggleSummaries();}
  126. }],
  127. frame: true,
  128. width: 800,
  129. height: 450,
  130. clicksToEdit: 1,
  131. collapsible: true,
  132. animCollapse: false,
  133. trackMouseOver: false,
  134. //enableColumnMove: false,
  135. title: 'Sponsored Projects',
  136. iconCls: 'icon-grid',
  137. renderTo: document.body
  138. });
  139. grid.on('afteredit', function(){
  140. var groupValue = 'Ext Forms: Field Anchoring';
  141. summary.showSummaryMsg(groupValue, 'Updating Summary...');
  142. setTimeout(function(){ // simulate server call
  143. // HybridSummary class implements updateSummaryData
  144. summary.updateSummaryData(groupValue,
  145. // create data object based on configured dataIndex
  146. {description: 22, estimate: 888, rate: 888, due: new Date(), cost: 8});
  147. }, 2000);
  148. });
  149. // load the remote data
  150. grid.store.load();
  151. });