incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cframp...@apache.org
Subject svn commit: r1409011 - in /incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses: GridColumn.as GridItemEditor.as
Date Tue, 13 Nov 2012 22:56:06 GMT
Author: cframpton
Date: Tue Nov 13 22:56:05 2012
New Revision: 1409011

URL: http://svn.apache.org/viewvc?rev=1409011&view=rev
Log:
FLEX-33248.  Fix Spark DataGrid default editor, GridItemEditor, so it handles complex data
fields such as "company.name".  Modified patch submitted by Maxime Cowez.

Modified:
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumn.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditor.as

Modified: incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumn.as
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumn.as?rev=1409011&r1=1409010&r2=1409011&view=diff
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumn.as
(original)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumn.as
Tue Nov 13 22:56:05 2012
@@ -276,7 +276,7 @@ public class GridColumn extends EventDis
     //----------------------------------
     
     private var _dataField:String = null;
-    private var dataFieldPath:Array = [];
+    mx_internal var dataFieldPath:Array = [];
     
     [Bindable("dataFieldChanged")]    
     
@@ -1587,7 +1587,7 @@ public class GridColumn extends EventDis
      *  Common logic for itemToLabel(), itemToDataTip().   Logically this code is
      *  similar to (not the same as) LabelUtil.itemToLabel().
      */
-    private function itemToString(item:Object, labelPath:Array, labelFunction:Function, formatter:IFormatter):String
+    mx_internal function itemToString(item:Object, labelPath:Array, labelFunction:Function,
formatter:IFormatter):String
     {
         if (!item)
             return ERROR_TEXT;

Modified: incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditor.as
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditor.as?rev=1409011&r1=1409010&r2=1409011&view=diff
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditor.as
(original)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditor.as
Tue Nov 13 22:56:05 2012
@@ -24,7 +24,6 @@ import flash.events.MouseEvent;
 import flash.geom.Point;
 import flash.utils.describeType;
 
-
 import mx.collections.ICollectionView;
 import mx.collections.ISort;
 import mx.core.IIMESupport;
@@ -32,12 +31,11 @@ import mx.core.IInvalidating;
 import mx.core.IVisualElement;
 import mx.core.IVisualElementContainer;
 import mx.core.mx_internal;
-import mx.core.UIComponent;
 import mx.validators.IValidatorListener;
 
-import spark.components.gridClasses.GridColumn;
 import spark.components.DataGrid;
 import spark.components.Group;
+import spark.components.gridClasses.GridColumn;
 
 use namespace mx_internal;
 
@@ -79,7 +77,7 @@ use namespace mx_internal;
 public class GridItemEditor extends Group implements IGridItemEditor
 {
     include "../../core/Version.as";    
-    
+        
     //--------------------------------------------------------------------------
     //
     //  Constructor
@@ -183,7 +181,11 @@ public class GridItemEditor extends Grou
         
         if (_data && column.dataField)
         {
-            this.value = _data[column.dataField];            
+            // If complex data need to dig the data value out of the correct object.
+            var dataFieldPath:Array = column.dataFieldPath;
+            this.value = column.dataFieldPath.length == 1 ?
+                _data[column.dataField] :
+                column.itemToString(_data, dataFieldPath, null, null);
         }
     }
 
@@ -458,9 +460,17 @@ public class GridItemEditor extends Grou
             return false;
         
         var newData:Object = value;
-        var property:String = column.dataField;
+        var property:String;
         var data:Object = data;
         var typeInfo:String = "";
+                        
+        // Handle complex data field by drilling down to the correct object.
+        // Complex data fields means dataFieldPath.length > 1.
+        for (var i:int = 0; i < column.dataFieldPath.length - 1; i++)
+            data = data[column.dataFieldPath[i]];
+        
+        property = column.dataFieldPath[i];
+            
         for each(var variable:XML in describeType(data).variable)
         {
             if (property == variable.@name.toString())
@@ -501,7 +511,7 @@ public class GridItemEditor extends Grou
                 }
             }
         }
-     
+
         if (property && data[property] !== newData)
         {
             // If the data is sorted, turn off the sort for the edited data.
@@ -515,7 +525,7 @@ public class GridItemEditor extends Grou
                     dataProvider.sort = null;
                 }
             }
-            
+
             var oldData:Object = data[property];
             data[property] = newData;
             dataGrid.dataProvider.itemUpdated(data, property, oldData, newData);
@@ -663,4 +673,4 @@ public class GridItemEditor extends Grou
         event.stopPropagation();
     }
 }
-}
\ No newline at end of file
+}



Mime
View raw message