Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / examples / grid / totals-hybrid.js
similarity index 51%
rename from examples/grid/hybrid-totals.js
rename to examples/grid/totals-hybrid.js
index 3405fd2..353406c 100644 (file)
@@ -1,11 +1,9 @@
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
+/*!
+ * Ext JS Library 3.0.0
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
 Ext.onReady(function(){\r
 \r
     Ext.QuickTips.init();\r
@@ -14,9 +12,6 @@ Ext.onReady(function(){
 \r
     var reader = new Ext.data.JsonReader({\r
         idProperty:'taskId',\r
-        root:'data',\r
-        remoteGroup:true,\r
-        remoteSort: true,\r
         fields: [\r
             {name: 'projectId', type: 'int'},\r
             {name: 'project', type: 'string'},\r
@@ -26,32 +21,37 @@ Ext.onReady(function(){
             {name: 'rate', type: 'float'},\r
             {name: 'cost', type: 'float'},\r
             {name: 'due', type: 'date', dateFormat:'m/d/Y'}\r
-        ]\r
-\r
+        ],\r
+               // additional configuration for remote\r
+        root:'data',\r
+        remoteGroup:true,\r
+        remoteSort: true\r
     });\r
 \r
     // define a custom summary function\r
-    Ext.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){\r
+    Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){\r
         return v + (record.data.estimate * record.data.rate);\r
-    }\r
+    };\r
 \r
-    var summary = new Ext.grid.HybridSummary(); \r
+       // utilize custom extension for Hybrid Summary\r
+    var summary = new Ext.ux.grid.HybridSummary();\r
 \r
     var grid = new xg.EditorGridPanel({\r
         ds: new Ext.data.GroupingStore({\r
             reader: reader,\r
+                       // use remote data\r
             proxy : new Ext.data.HttpProxy({\r
-                url: 'summary.json',\r
+                url: 'totals-hybrid.json',\r
                 method: 'GET'\r
             }),\r
-            sortInfo:{field: 'due', direction: "ASC"},\r
-            groupField:'project'\r
+            sortInfo: {field: 'due', direction: 'ASC'},\r
+            groupField: 'project'\r
         }),\r
 \r
         columns: [\r
             {\r
                 id: 'description',\r
-                header: "Task",\r
+                header: 'Task',\r
                 width: 80,\r
                 sortable: true,\r
                 dataIndex: 'description',\r
@@ -64,12 +64,12 @@ Ext.onReady(function(){
                    allowBlank: false\r
                 })\r
             },{\r
-                header: "Project",\r
+                header: 'Project',\r
                 width: 20,\r
                 sortable: true,\r
                 dataIndex: 'project'\r
             },{\r
-                header: "Due Date",\r
+                header: 'Due Date',\r
                 width: 25,\r
                 sortable: true,\r
                 dataIndex: 'due',\r
@@ -79,7 +79,7 @@ Ext.onReady(function(){
                     format: 'm/d/Y'\r
                 })\r
             },{\r
-                header: "Estimate",\r
+                header: 'Estimate',\r
                 width: 20,\r
                 sortable: true,\r
                 dataIndex: 'estimate',\r
@@ -93,7 +93,7 @@ Ext.onReady(function(){
                     style: 'text-align:left'\r
                 })\r
             },{\r
-                header: "Rate",\r
+                header: 'Rate',\r
                 width: 20,\r
                 sortable: true,\r
                 renderer: Ext.util.Format.usMoney,\r
@@ -106,7 +106,7 @@ Ext.onReady(function(){
                 })\r
             },{\r
                 id: 'cost',\r
-                header: "Cost",\r
+                header: 'Cost',\r
                 width: 20,\r
                 sortable: false,\r
                 groupable: false,\r
@@ -114,7 +114,7 @@ Ext.onReady(function(){
                     return Ext.util.Format.usMoney(record.data.estimate * record.data.rate);\r
                 },\r
                 dataIndex: 'cost',\r
-                summaryType:'totalCost',\r
+                summaryType: 'totalCost',\r
                 summaryRenderer: Ext.util.Format.usMoney\r
             }\r
         ],\r
@@ -122,6 +122,8 @@ Ext.onReady(function(){
         view: new Ext.grid.GroupingView({\r
             forceFit:true,\r
             showGroupName: false,\r
+            enableNoGroups:false,\r
+                       enableGroupingMenu:false,\r
             hideGroupedColumn: true\r
         }),\r
 \r
@@ -129,10 +131,11 @@ Ext.onReady(function(){
 \r
         tbar : [{\r
             text: 'Toggle',\r
+            tooltip: 'Toggle the visibility of summary row',\r
             handler: function(){summary.toggleSummaries();}\r
         }],\r
 \r
-        frame:true,\r
+        frame: true,\r
         width: 800,\r
         height: 450,\r
         clicksToEdit: 1,\r
@@ -149,35 +152,14 @@ Ext.onReady(function(){
         var groupValue = 'Ext Forms: Field Anchoring';\r
         summary.showSummaryMsg(groupValue, 'Updating Summary...');\r
         setTimeout(function(){ // simulate server call\r
+            // HybridSummary class implements updateSummaryData\r
             summary.updateSummaryData(groupValue,\r
-                {due: new Date(2007, 6, 29), estimate: 21, rate: 185, cost: 2900});\r
+                // create data object based on configured dataIndex\r
+                {description: 22, estimate: 888, rate: 888, due: new Date(), cost: 8});\r
         }, 2000);\r
     });\r
 \r
+       // load the remote data\r
     grid.store.load();\r
-});\r
 \r
-Ext.grid.dummyProjects = [\r
-    {projectId: 100, project: 'Ext Forms: Field Anchoring'},\r
-    {projectId: 101, project: 'Ext Grid: Single-level Grouping'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows'}\r
-];\r
-\r
-Ext.grid.dummyData = [\r
-    {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'},\r
-    {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 113, description: 'Implement AnchorLayout', estimate: 4, rate: 150, due:'06/25/2007'},\r
-    {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'},\r
-    {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 115, description: 'Testing and debugging', estimate: 8, rate: 0, due:'06/29/2007'},\r
-    {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'},\r
-    {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'},\r
-    {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 103, description: 'Extend Store with grouping functionality', estimate: 4, rate: 100, due:'07/04/2007'},\r
-    {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 121, description: 'Default CSS Styling', estimate: 2, rate: 100, due:'07/05/2007'},\r
-    {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 104, description: 'Testing and debugging', estimate: 6, rate: 100, due:'07/06/2007'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 105, description: 'Ext Grid plugin integration', estimate: 4, rate: 125, due:'07/01/2007'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 106, description: 'Summary creation during rendering phase', estimate: 4, rate: 125, due:'07/02/2007'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 107, description: 'Dynamic summary updates in editor grids', estimate: 6, rate: 125, due:'07/05/2007'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 108, description: 'Remote summary integration', estimate: 4, rate: 125, due:'07/05/2007'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 109, description: 'Summary renderers and calculators', estimate: 4, rate: 125, due:'07/06/2007'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 110, description: 'Integrate summaries with GroupingView', estimate: 10, rate: 125, due:'07/11/2007'},\r
-    {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 111, description: 'Testing and debugging', estimate: 8, rate: 125, due:'07/15/2007'}\r
-];
\ No newline at end of file
+});\r