1 Reply Latest reply on Jun 13, 2008 5:18 AM by bre358

    Need some assistance with dynamic database updates done through a loop

    bre358
      In the part of my application that I'm currently working on I'm trying to dynamically update a local database every time a change is made to the dataProvider(ArrayCollection) when a dragDrop action is done. After doing some more research I found that the update "function"(my trace placeholder) is fine where it is, the problem is that it is firing the insert function for each and every row every time something is dragged onto the datagrid essentially cloning all the entries in the database while updating the original items. So I've narrowed down my problem to figuring out how to get the insert function to fire only once for new items and skipped when updating items. The database is a local as this is an AIR app, I'm posting this here since I feel this is more of a flex issue than an AIR issue. I've already tried adding an else clause to the if statement but that doesn't work along with else if. Thanks in advance.

      Here's my code so far:
        • 1. Re: Need some assistance with dynamic database updates done through a loop
          bre358 Level 1
          Ok, one thing I'm going to try today is this; essentially I'm going to
          say, "forget that for-loop, just let it update the dataProvider". What
          I'm going to do is write another function that runs each row of the dp
          through a filterFunction and checks to see if it is there or not, if
          it is there, then update the editable values, if not, then insert a
          new row. Since this would be invoked after the dataProvider update, I
          may just save it until the user closes the window in any way and then
          run this as a save and quit function. It would also help to be able to
          have it available in a button.

          If anyone has a better idea on how to do this, don't hesitate to tell me.