6 Replies Latest reply on Aug 12, 2008 9:59 AM by Newsgroup_User

    Trouble with Tree Drag

    adeelmahmood
      I am having a weird problem with dragging items from a tree to a data grid .. everytime I drag an item from the tree (xmllist) to the datagrid I am adding that item (xml node) to the datagrid dataprovider which is a xmlListCollection .. it adds the item to the datagrid just fine but also adds a duplicate of the item that was dragged, in the tree ..
      So I end up having two of the same items in the tree
      I have attached the pieces of code being used

      I would appreciate if anyone can point out what I am doing wrong or wats going on with this thing
      Thanks
        • 1. Re: Trouble with Tree Drag
          adeelmahmood Level 1
          Note:
          I have obviously done quite a bit of debugging and it seems like on the last line where I am adding to the target datagrid dataprovider
          //add to target datagrid
          xmlSelectFields.addItem(node);
          it also adds this item to the tree dataprovider
          • 2. Re: Trouble with Tree Drag
            Level 7

            "adeelmahmood" <webforumsuser@macromedia.com> wrote in message
            news:g7s9e6$hud$1@forums.macromedia.com...
            > Note:
            > I have obviously done quite a bit of debugging and it seems like on the
            > last
            > line where I am adding to the target datagrid dataprovider
            > //add to target datagrid
            > xmlSelectFields.addItem(node);
            > it also adds this item to the tree dataprovider
            How are you setting the dataProvider on the tree


            • 3. Trouble with Tree Drag
              adeelmahmood Level 1
              //tree dataprovider is being set in an creationComplete event .. from xml returned from a webservice
              treeTables.dataProvider = retXml.Data.tables.table;

              this is how the xml looks like
              <tables>
              <table title="Table 1">
              <field name="field A" parent="Table 1" selected="true" />
              <field name="field A" parent="Table 1" selected="false" />
              </table>
              ...
              </tables>
              • 4. Re: Trouble with Tree Drag
                Level 7

                "adeelmahmood" <webforumsuser@macromedia.com> wrote in message
                news:g7sc5r$l1m$1@forums.macromedia.com...
                > //tree dataprovider is being set in an creationComplete event .. from xml
                > returned from a webservice
                > treeTables.dataProvider = retXml.Data.tables.table;
                >
                > this is how the xml looks like
                > <table title="Table 1">
                > <field name="field A" parent="Table 1" selected="true" />
                > <field name="field A" parent="Table 1" selected="false" />
                > </table>

                Is there any binding at all involved in the situation? Usually, people have
                a problem with the objects being taken _out_ of the source component, not
                added _in_.


                • 5. Re: Trouble with Tree Drag
                  adeelmahmood Level 1
                  I am not sure I understand your question ..
                  There is binding involved .. I just didnt do that in the case of the tree dataprovider because I thought its because of the binding that I am getting this problems .. It almost seems that the two dataproviders are also binded to each other so adding something to one also adds it to other
                  I had the binding dataprovider setup on the tree before . but I changed that to see if that would fix the problem ..
                  this is how it was setup
                  [Bindable]
                  public var xmlTables:XMLList = new XMLList();

                  and the tree was defined like this
                  <mx:Tree id="treeTables" x="10" y="10" width="90%" height="97%" labelFunction="treeLabel" dragEnabled="true" dragMoveEnabled="false" dataProvider="{xmlTables}" />

                  then in that case the creationComplete event was doing this
                  xmlTables = new XMLList(retXml.Data.tables.table);
                  • 6. Re: Trouble with Tree Drag
                    Level 7

                    "adeelmahmood" <webforumsuser@macromedia.com> wrote in message
                    news:g7se7h$n6c$1@forums.macromedia.com...
                    >I am not sure I understand your question ..
                    > There is binding involved .. I just didnt do that in the case of the tree
                    > dataprovider because I thought its because of the binding that I am
                    > getting
                    > this problems .. It almost seems that the two dataproviders are also
                    > binded to
                    > each other so adding something to one also adds it to other
                    > I had the binding dataprovider setup on the tree before . but I changed
                    > that
                    > to see if that would fix the problem ..
                    > this is how it was setup
                    > [Bindable]
                    > public var xmlTables:XMLList = new XMLList();
                    >
                    > and the tree was defined like this
                    > <mx:Tree id="treeTables" x="10" y="10" width="90%" height="97%"
                    > labelFunction="treeLabel" dragEnabled="true" dragMoveEnabled="false"
                    > dataProvider="{xmlTables}" />
                    >
                    > then in that case the creationComplete event was doing this
                    > xmlTables = new XMLList(retXml.Data.tables.table);

                    Try making both the dataProviders XMLListCollections.

                    HTH;

                    Amy