e5ce5a26f6bc0ab0de51995b96881d1509b182a7.svn-base 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.onReady(function() {
  7. Ext.QuickTips.init();
  8. var xg = Ext.grid;
  9. var reader = new Ext.data.JsonReader({
  10. idProperty : 'taskId',
  11. fields : [{
  12. name : 'projectId',
  13. type : 'int'
  14. }, {
  15. name : 'project',
  16. type : 'string'
  17. }, {
  18. name : 'taskId',
  19. type : 'int'
  20. }, {
  21. name : 'description',
  22. type : 'string'
  23. }, {
  24. name : 'estimate',
  25. type : 'float'
  26. }, {
  27. name : 'rate',
  28. type : 'float'
  29. }, {
  30. name : 'cost',
  31. type : 'float'
  32. }, {
  33. name : 'due',
  34. type : 'date',
  35. dateFormat : 'm/d/Y'
  36. }]
  37. });
  38. // define a custom summary function
  39. Ext.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field) {
  40. return v + (record.data.estimate * record.data.rate);
  41. }
  42. var summary = new Ext.grid.GroupSummary();
  43. var grid = new xg.EditorGridPanel({
  44. ds : new Ext.data.GroupingStore({
  45. reader : reader,
  46. data : xg.dummyData,
  47. sortInfo : {
  48. field : 'due',
  49. direction : "ASC"
  50. },
  51. groupField : 'project'
  52. }),
  53. columns : [{
  54. id : 'description',
  55. header : "Task",
  56. width : 80,
  57. sortable : true,
  58. dataIndex : 'description',
  59. summaryType : 'count',
  60. hideable : false,
  61. summaryRenderer : function(v, params, data) {
  62. return ((v === 0 || v > 1)
  63. ? '(' + v + ' Tasks)'
  64. : '(1 Task)');
  65. },
  66. editor : new Ext.form.TextField({
  67. allowBlank : false
  68. })
  69. }, {
  70. header : "Project",
  71. width : 20,
  72. sortable : true,
  73. dataIndex : 'project'
  74. }, {
  75. header : "Due Date",
  76. width : 25,
  77. sortable : true,
  78. dataIndex : 'due',
  79. summaryType : 'max',
  80. renderer : Ext.util.Format.dateRenderer('m/d/Y'),
  81. editor : new Ext.form.DateField({
  82. format : 'm/d/Y'
  83. })
  84. }, {
  85. header : "Estimate",
  86. width : 20,
  87. sortable : true,
  88. dataIndex : 'estimate',
  89. summaryType : 'sum',
  90. renderer : function(v) {
  91. return v + ' hours';
  92. },
  93. editor : new Ext.form.NumberField({
  94. allowBlank : false,
  95. allowNegative : false,
  96. style : 'text-align:left'
  97. })
  98. }, {
  99. header : "Rate",
  100. width : 20,
  101. sortable : true,
  102. renderer : Ext.util.Format.usMoney,
  103. dataIndex : 'rate',
  104. summaryType : 'average',
  105. editor : new Ext.form.NumberField({
  106. allowBlank : false,
  107. allowNegative : false,
  108. style : 'text-align:left'
  109. })
  110. }, {
  111. id : 'cost',
  112. header : "Cost",
  113. width : 20,
  114. sortable : false,
  115. groupable : false,
  116. renderer : function(v, params, record) {
  117. return Ext.util.Format.usMoney(record.data.estimate
  118. * record.data.rate);
  119. },
  120. dataIndex : 'cost',
  121. summaryType : 'totalCost',
  122. summaryRenderer : Ext.util.Format.usMoney
  123. }],
  124. view : new Ext.grid.GroupingView({
  125. forceFit : true,
  126. showGroupName : false,
  127. enableNoGroups : false, // REQUIRED!
  128. hideGroupedColumn : true
  129. }),
  130. plugins : summary,
  131. frame : true,
  132. width : 800,
  133. height : 450,
  134. clicksToEdit : 1,
  135. collapsible : true,
  136. animCollapse : false,
  137. trackMouseOver : false,
  138. // enableColumnMove: false,
  139. title : 'Sponsored Projects',
  140. iconCls : 'icon-grid',
  141. renderTo : document.body
  142. });
  143. });
  144. Ext.grid.dummyProjects = [{
  145. projectId : 100,
  146. project : 'Ext Forms: Field Anchoring'
  147. }, {
  148. projectId : 101,
  149. project : 'Ext Grid: Single-level Grouping'
  150. }, {
  151. projectId : 102,
  152. project : 'Ext Grid: Summary Rows'
  153. }];
  154. Ext.grid.dummyData = [{
  155. projectId : 100,
  156. project : 'Ext Forms: Field Anchoring',
  157. taskId : 112,
  158. description : 'Integrate 2.0 Forms with 2.0 Layouts',
  159. estimate : 6,
  160. rate : 150,
  161. due : '06/24/2007'
  162. }, {
  163. projectId : 100,
  164. project : 'Ext Forms: Field Anchoring',
  165. taskId : 113,
  166. description : 'Implement AnchorLayout',
  167. estimate : 4,
  168. rate : 150,
  169. due : '06/25/2007'
  170. }, {
  171. projectId : 100,
  172. project : 'Ext Forms: Field Anchoring',
  173. taskId : 114,
  174. description : 'Add support for multiple types of anchors',
  175. estimate : 4,
  176. rate : 150,
  177. due : '06/27/2007'
  178. }, {
  179. projectId : 100,
  180. project : 'Ext Forms: Field Anchoring',
  181. taskId : 115,
  182. description : 'Testing and debugging',
  183. estimate : 8,
  184. rate : 0,
  185. due : '06/29/2007'
  186. }, {
  187. projectId : 101,
  188. project : 'Ext Grid: Single-level Grouping',
  189. taskId : 101,
  190. description : 'Add required rendering "hooks" to GridView',
  191. estimate : 6,
  192. rate : 100,
  193. due : '07/01/2007'
  194. }, {
  195. projectId : 101,
  196. project : 'Ext Grid: Single-level Grouping',
  197. taskId : 102,
  198. description : 'Extend GridView and override rendering functions',
  199. estimate : 6,
  200. rate : 100,
  201. due : '07/03/2007'
  202. }, {
  203. projectId : 101,
  204. project : 'Ext Grid: Single-level Grouping',
  205. taskId : 103,
  206. description : 'Extend Store with grouping functionality',
  207. estimate : 4,
  208. rate : 100,
  209. due : '07/04/2007'
  210. }, {
  211. projectId : 101,
  212. project : 'Ext Grid: Single-level Grouping',
  213. taskId : 121,
  214. description : 'Default CSS Styling',
  215. estimate : 2,
  216. rate : 100,
  217. due : '07/05/2007'
  218. }, {
  219. projectId : 101,
  220. project : 'Ext Grid: Single-level Grouping',
  221. taskId : 104,
  222. description : 'Testing and debugging',
  223. estimate : 6,
  224. rate : 100,
  225. due : '07/06/2007'
  226. }, {
  227. projectId : 102,
  228. project : 'Ext Grid: Summary Rows',
  229. taskId : 105,
  230. description : 'Ext Grid plugin integration',
  231. estimate : 4,
  232. rate : 125,
  233. due : '07/01/2007'
  234. }, {
  235. projectId : 102,
  236. project : 'Ext Grid: Summary Rows',
  237. taskId : 106,
  238. description : 'Summary creation during rendering phase',
  239. estimate : 4,
  240. rate : 125,
  241. due : '07/02/2007'
  242. }, {
  243. projectId : 102,
  244. project : 'Ext Grid: Summary Rows',
  245. taskId : 107,
  246. description : 'Dynamic summary updates in editor grids',
  247. estimate : 6,
  248. rate : 125,
  249. due : '07/05/2007'
  250. }, {
  251. projectId : 102,
  252. project : 'Ext Grid: Summary Rows',
  253. taskId : 108,
  254. description : 'Remote summary integration',
  255. estimate : 4,
  256. rate : 125,
  257. due : '07/05/2007'
  258. }, {
  259. projectId : 102,
  260. project : 'Ext Grid: Summary Rows',
  261. taskId : 109,
  262. description : 'Summary renderers and calculators',
  263. estimate : 4,
  264. rate : 125,
  265. due : '07/06/2007'
  266. }, {
  267. projectId : 102,
  268. project : 'Ext Grid: Summary Rows',
  269. taskId : 110,
  270. description : 'Integrate summaries with GroupingView',
  271. estimate : 10,
  272. rate : 125,
  273. due : '07/11/2007'
  274. }, {
  275. projectId : 102,
  276. project : 'Ext Grid: Summary Rows',
  277. taskId : 111,
  278. description : 'Testing and debugging',
  279. estimate : 8,
  280. rate : 125,
  281. due : '07/15/2007'
  282. }];