3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.onReady(function(){
\r
10 Ext.QuickTips.init();
\r
14 var reader = new Ext.data.JsonReader({
\r
15 idProperty:'taskId',
\r
17 {name: 'projectId', type: 'int'},
\r
18 {name: 'project', type: 'string'},
\r
19 {name: 'taskId', type: 'int'},
\r
20 {name: 'description', type: 'string'},
\r
21 {name: 'estimate', type: 'float'},
\r
22 {name: 'rate', type: 'float'},
\r
23 {name: 'cost', type: 'float'},
\r
24 {name: 'due', type: 'date', dateFormat:'m/d/Y'}
\r
26 // additional configuration for remote
\r
32 // define a custom summary function
\r
33 Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
\r
34 return v + (record.data.estimate * record.data.rate);
\r
37 // utilize custom extension for Hybrid Summary
\r
38 var summary = new Ext.ux.grid.HybridSummary();
\r
40 var grid = new xg.EditorGridPanel({
\r
41 ds: new Ext.data.GroupingStore({
\r
44 proxy : new Ext.data.HttpProxy({
\r
45 url: 'totals-hybrid.json',
\r
48 sortInfo: {field: 'due', direction: 'ASC'},
\r
49 groupField: 'project'
\r
58 dataIndex: 'description',
\r
59 summaryType: 'count',
\r
61 summaryRenderer: function(v, params, data){
\r
62 return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
\r
64 editor: new Ext.form.TextField({
\r
71 dataIndex: 'project'
\r
78 renderer: Ext.util.Format.dateRenderer('m/d/Y'),
\r
79 editor: new Ext.form.DateField({
\r
86 dataIndex: 'estimate',
\r
88 renderer : function(v){
\r
91 editor: new Ext.form.NumberField({
\r
93 allowNegative: false,
\r
94 style: 'text-align:left'
\r
100 renderer: Ext.util.Format.usMoney,
\r
102 summaryType:'average',
\r
103 editor: new Ext.form.NumberField({
\r
105 allowNegative: false,
\r
106 style: 'text-align:left'
\r
114 renderer: function(v, params, record){
\r
115 return Ext.util.Format.usMoney(record.data.estimate * record.data.rate);
\r
118 summaryType: 'totalCost',
\r
119 summaryRenderer: Ext.util.Format.usMoney
\r
123 view: new Ext.grid.GroupingView({
\r
125 showGroupName: false,
\r
126 enableNoGroups:false,
\r
127 enableGroupingMenu:false,
\r
128 hideGroupedColumn: true
\r
135 tooltip: 'Toggle the visibility of summary row',
\r
136 handler: function(){summary.toggleSummaries();}
\r
144 animCollapse: false,
\r
145 trackMouseOver: false,
\r
146 //enableColumnMove: false,
\r
147 title: 'Sponsored Projects',
\r
148 iconCls: 'icon-grid',
\r
149 renderTo: document.body
\r
152 grid.on('afteredit', function(){
\r
153 var groupValue = 'Ext Forms: Field Anchoring';
\r
154 summary.showSummaryMsg(groupValue, 'Updating Summary...');
\r
155 setTimeout(function(){ // simulate server call
\r
156 // HybridSummary class implements updateSummaryData
\r
157 summary.updateSummaryData(groupValue,
\r
158 // create data object based on configured dataIndex
\r
159 {description: 22, estimate: 888, rate: 888, due: new Date(), cost: 8});
\r
163 // load the remote data
\r