Here is some example code that can recreate the problem. Run it and on the last node, drag a row to just below the last row, as if trying to make it last in the group....you will notice that instead, it takes the row and converts it to a new node...sort of....

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute">
   <mx:Script>
       <![CDATA[
           import mx.collections.ArrayCollection;
[Bindable]
           private var dpFlat:ArrayCollection = new ArrayCollection([
             {Region:"North", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"North", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"North", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"North", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"North", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"North", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"North", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"North", Territory:"Southern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

             {Region:"South", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"South", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"South", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"South", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"South", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"South", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"South", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"South", Territory:"Southern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

             {Region:"East", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"East", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"East", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"East", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"East", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"East", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"East", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"East", Territory:"Southern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

             {Region:"West", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"West", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"West", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"West", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"West", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"West", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"West", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"West", Territory:"Southern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

             {Region:"Northwest", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"Northwest", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"Northwest", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"Northwest", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"Northwest", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"Northwest", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"Northwest", Territory:"Northern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"Northwest", Territory:"Northern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

             {Region:"Northeast", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"Northeast", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"Northeast", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"Northeast", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"Northeast", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"Northeast", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"Northeast", Territory:"Northern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"Northeast", Territory:"Northern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

             {Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"Southwest", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"Southwest", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"Southwest", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"Southwest", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"Southwest", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"Southwest", Territory:"Southern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

             {Region:"Southeast", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
             {Region:"Southeast", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, {Region:"Southeast", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, {Region:"Southeast", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, {Region:"Southeast", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
             {Region:"Southeast", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, {Region:"Southeast", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
             {Region:"Southeast", Territory:"Southern California",
                 Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}

           ]);
       ]]>
   </mx:Script>

<mx:VBox width="100%" height="100%">
       <mx:Panel title="AdvancedDataGrid Control Example"
           height="75%" width="75%" layout="horizontal"
paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"> <mx:AdvancedDataGrid id="myADG"
               width="100%" height="100%"
               initialize="gc.refresh();"
dragEnabled="true" dragMoveEnabled="true" dropEnabled="true"> <mx:dataProvider>
                   <mx:GroupingCollection id="gc" source="{dpFlat}">
                       <mx:grouping>
                           <mx:Grouping>
                               <mx:GroupingField name="Region"/>
                           </mx:Grouping>
                       </mx:grouping>
                   </mx:GroupingCollection>
</mx:dataProvider> <mx:columns>
                   <mx:AdvancedDataGridColumn dataField="Region"/>
                   <mx:AdvancedDataGridColumn dataField="Territory"/>
                   <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                       headerText="Territory Rep"/>
                   <mx:AdvancedDataGridColumn dataField="Actual"/>
                   <mx:AdvancedDataGridColumn dataField="Estimate"/>
               </mx:columns>

</mx:AdvancedDataGrid>
       </mx:Panel>

      <mx:HBox width="100%">
<mx:Button id="expandAllButton" click="{myADG.expandAll();}" label="Expand All"/> <mx:Button id="collapseAllButton" click="{myADG.collapseAll();}" label="Collapse All"/>
      </mx:HBox>

   </mx:VBox>

</mx:Application>


Adrian Williams wrote:

All,

I have an ADG that contains a grouped collection. In the dataset, there are 21 nodes...each node has 1 to many children. When I attempt to drag a row, either from another node or within the last node, and drop it below the last item in the last node(i.e. make it the very last row in the group and ADG overall), the systems treats it like I'm trying to drop it at the node level instead of the child level and throws an out of bounds (which is probably due to my code that persists the orders in the database). In watching it in debugger, here are the values that occur. Here's the setup: 21 groups (nodes) in the adg.
    The last group has 4 children (rows).

If I expand only the last node...and drag the first row of that node to the next to last row, the adg.dropData.index == 3 and the adg.dropData.parent == the node object that I am in, which is should because I am dropping it within that grouping. If I drag the first row of that node to just below the last row, intending on making it last in the group, the adg.dropData.index == 25 and the adg.dropData.parent == null. It obvious that the adg doesn't realize that I am dropping it within the last position of the group because it's the final row in the overall adg. So I tried to outsmart it. I created a handler to determine if the adg.dropData.index >= (the hierarchical tree length + the length of the all the open nodes in the tree), using the assumption that if this is true, then the user is trying to put the row at the end (keep in mind I am also checking to make sure it's not a node that is being dragged to reorder). If this is true, then I manipulate the actual event.dragInitiator._dropData and the adg.dropData values and force the index (which I calculate from the number of children in the last node) and parent information into them.

To a point, this works and my drop is persisted to my database per design. However, the dropped row disappears from the grid, only appearing in its correct position on refreshing the grid.

The problem appears in the AdvancedDataGrid.as class.....within the updateDropData function where calculations are being done to re-place the row...because the index value is 25, the top and bottom parent calculations seem to get all jacked up and in the end, the _dropData gets reset to the old values, completely overriding my efforts to cheat.

Has anyone else ever seen this...know of a way to get around it. It certainly seems like an Adobe bug to me.

Best,
Adrian

Reply via email to