3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 Ext.onReady(function(){
13 var reader = new Ext.data.JsonReader({
16 {name: 'projectId', type: 'int'},
17 {name: 'project', type: 'string'},
18 {name: 'taskId', type: 'int'},
19 {name: 'description', type: 'string'},
20 {name: 'estimate', type: 'float'},
21 {name: 'rate', type: 'float'},
22 {name: 'cost', type: 'float'},
23 {name: 'due', type: 'date', dateFormat:'m/d/Y'}
28 // define a custom summary function
29 Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
30 return v + (record.data.estimate * record.data.rate);
33 // utilize custom extension for Group Summary
34 var summary = new Ext.ux.grid.GroupSummary();
36 var grid = new xg.EditorGridPanel({
37 ds: new Ext.data.GroupingStore({
40 data: app.grid.dummyData,
41 sortInfo: {field: 'due', direction: 'ASC'},
50 dataIndex: 'description',
53 summaryRenderer: function(v, params, data){
54 return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
56 editor: new Ext.form.TextField({
70 renderer: Ext.util.Format.dateRenderer('m/d/Y'),
71 editor: new Ext.form.DateField({
78 dataIndex: 'estimate',
80 renderer : function(v){
83 editor: new Ext.form.NumberField({
86 style: 'text-align:left'
92 renderer: Ext.util.Format.usMoney,
94 summaryType: 'average',
95 editor: new Ext.form.NumberField({
98 style: 'text-align:left'
106 renderer: function(v, params, record){
107 return Ext.util.Format.usMoney(record.data.estimate * record.data.rate);
110 summaryType: 'totalCost',
111 summaryRenderer: Ext.util.Format.usMoney
115 view: new Ext.grid.GroupingView({
117 showGroupName: false,
118 enableNoGroups: false,
119 enableGroupingMenu: false,
120 hideGroupedColumn: true
127 tooltip: 'Toggle the visibility of summary row',
128 handler: function(){summary.toggleSummaries();}
137 trackMouseOver: false,
138 //enableColumnMove: false,
139 title: 'Sponsored Projects',
140 iconCls: 'icon-grid',
141 renderTo: document.body
146 // set up namespace for application
148 // store dummy data in the app namespace
149 app.grid.dummyData = [
150 {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'},
151 {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 113, description: 'Implement AnchorLayout', estimate: 4, rate: 150, due:'06/25/2007'},
152 {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'},
153 {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 115, description: 'Testing and debugging', estimate: 8, rate: 0, due:'06/29/2007'},
154 {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'},
155 {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'},
156 {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 103, description: 'Extend Store with grouping functionality', estimate: 4, rate: 100, due:'07/04/2007'},
157 {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 121, description: 'Default CSS Styling', estimate: 2, rate: 100, due:'07/05/2007'},
158 {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 104, description: 'Testing and debugging', estimate: 6, rate: 100, due:'07/06/2007'},
159 {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 105, description: 'Ext Grid plugin integration', estimate: 4, rate: 125, due:'07/01/2007'},
160 {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 106, description: 'Summary creation during rendering phase', estimate: 4, rate: 125, due:'07/02/2007'},
161 {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 107, description: 'Dynamic summary updates in editor grids', estimate: 6, rate: 125, due:'07/05/2007'},
162 {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 108, description: 'Remote summary integration', estimate: 4, rate: 125, due:'07/05/2007'},
163 {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 109, description: 'Summary renderers and calculators', estimate: 4, rate: 125, due:'07/06/2007'},
164 {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 110, description: 'Integrate summaries with GroupingView', estimate: 10, rate: 125, due:'07/11/2007'},
165 {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 111, description: 'Testing and debugging', estimate: 8, rate: 125, due:'07/15/2007'}