source: trunk/web/addons/job_monarch/lib/extjs/examples/grid/totals.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 7.0 KB
Line 
1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9Ext.onReady(function(){
10
11    Ext.QuickTips.init();
12
13    var xg = Ext.grid;
14
15    var reader = new Ext.data.JsonReader({
16        idProperty:'taskId',
17        fields: [
18            {name: 'projectId', type: 'int'},
19            {name: 'project', type: 'string'},
20            {name: 'taskId', type: 'int'},
21            {name: 'description', type: 'string'},
22            {name: 'estimate', type: 'float'},
23            {name: 'rate', type: 'float'},
24            {name: 'cost', type: 'float'},
25            {name: 'due', type: 'date', dateFormat:'m/d/Y'}
26        ]
27
28    });
29
30    // define a custom summary function
31    Ext.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
32        return v + (record.data.estimate * record.data.rate);
33    }
34
35    var summary = new Ext.grid.GroupSummary(); 
36
37    var grid = new xg.EditorGridPanel({
38        ds: new Ext.data.GroupingStore({
39            reader: reader,
40            data: xg.dummyData,
41            sortInfo:{field: 'due', direction: "ASC"},
42            groupField:'project'
43        }),
44
45        columns: [
46            {
47                id: 'description',
48                header: "Task",
49                width: 80,
50                sortable: true,
51                dataIndex: 'description',
52                summaryType: 'count',
53                hideable: false,
54                summaryRenderer: function(v, params, data){
55                    return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
56                },
57                editor: new Ext.form.TextField({
58                   allowBlank: false
59                })
60            },{
61                header: "Project",
62                width: 20,
63                sortable: true,
64                dataIndex: 'project'
65            },{
66                header: "Due Date",
67                width: 25,
68                sortable: true,
69                dataIndex: 'due',
70                summaryType:'max',
71                renderer: Ext.util.Format.dateRenderer('m/d/Y'),
72                editor: new Ext.form.DateField({
73                    format: 'm/d/Y'
74                })
75            },{
76                header: "Estimate",
77                width: 20,
78                sortable: true,
79                dataIndex: 'estimate',
80                summaryType:'sum',
81                renderer : function(v){
82                    return v +' hours';
83                },
84                editor: new Ext.form.NumberField({
85                   allowBlank: false,
86                   allowNegative: false,
87                   style: 'text-align:left'
88                })
89            },{
90                header: "Rate",
91                width: 20,
92                sortable: true,
93                renderer: Ext.util.Format.usMoney,
94                dataIndex: 'rate',
95                summaryType:'average',
96                editor: new Ext.form.NumberField({
97                    allowBlank: false,
98                    allowNegative: false,
99                    style: 'text-align:left'
100                })
101            },{
102                id: 'cost',
103                header: "Cost",
104                width: 20,
105                sortable: false,
106                groupable: false,
107                renderer: function(v, params, record){
108                    return Ext.util.Format.usMoney(record.data.estimate * record.data.rate);
109                },
110                dataIndex: 'cost',
111                summaryType:'totalCost',
112                summaryRenderer: Ext.util.Format.usMoney
113            }
114        ],
115
116        view: new Ext.grid.GroupingView({
117            forceFit:true,
118            showGroupName: false,
119            enableNoGroups:false, // REQUIRED!
120            hideGroupedColumn: true
121        }),
122
123        plugins: summary,
124
125        frame:true,
126        width: 800,
127        height: 450,
128        clicksToEdit: 1,
129        collapsible: true,
130        animCollapse: false,
131        trackMouseOver: false,
132        //enableColumnMove: false,
133        title: 'Sponsored Projects',
134        iconCls: 'icon-grid',
135        renderTo: document.body
136    });
137});
138
139Ext.grid.dummyProjects = [
140    {projectId: 100, project: 'Ext Forms: Field Anchoring'},
141    {projectId: 101, project: 'Ext Grid: Single-level Grouping'},
142    {projectId: 102, project: 'Ext Grid: Summary Rows'}
143];
144
145Ext.grid.dummyData = [
146    {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'},
147    {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 113, description: 'Implement AnchorLayout', estimate: 4, rate: 150, due:'06/25/2007'},
148    {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'},
149    {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 115, description: 'Testing and debugging', estimate: 8, rate: 0, due:'06/29/2007'},
150    {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'},
151    {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'},
152    {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 103, description: 'Extend Store with grouping functionality', estimate: 4, rate: 100, due:'07/04/2007'},
153    {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 121, description: 'Default CSS Styling', estimate: 2, rate: 100, due:'07/05/2007'},
154    {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 104, description: 'Testing and debugging', estimate: 6, rate: 100, due:'07/06/2007'},
155    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 105, description: 'Ext Grid plugin integration', estimate: 4, rate: 125, due:'07/01/2007'},
156    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 106, description: 'Summary creation during rendering phase', estimate: 4, rate: 125, due:'07/02/2007'},
157    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 107, description: 'Dynamic summary updates in editor grids', estimate: 6, rate: 125, due:'07/05/2007'},
158    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 108, description: 'Remote summary integration', estimate: 4, rate: 125, due:'07/05/2007'},
159    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 109, description: 'Summary renderers and calculators', estimate: 4, rate: 125, due:'07/06/2007'},
160    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 110, description: 'Integrate summaries with GroupingView', estimate: 10, rate: 125, due:'07/11/2007'},
161    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 111, description: 'Testing and debugging', estimate: 8, rate: 125, due:'07/15/2007'}
162];
Note: See TracBrowser for help on using the repository browser.