3 Replies Latest reply on Nov 24, 2008 6:51 PM by alice_data

    How to Make SelectedItem be a Dynamic Variable?

    alice_data Level 1
      Hi,

      My client wanted me to create something that allows certain DataGrid to display to allow users to edit and update the database records. The only dilemma I am having here is how to actually create something from Flex's end to allow users update several rows of the database at once. Since everything in my HTTPService is in DataGrid, how can I get Flex to recognize each of the updated variables while I update the database? I tried using dg. .id in my code, but I kept getting errors that say it is not defined. Is there some way where I can make selectedItem be a dynamic variable?

      Thanks in advance.

      Alice

      This is the current code I have:

      Attach Code:

      <mx:HTTPService id="save_scenario" method="POST" url=" http://localhost/save_scenario.php" useProxy="false">
      <mx:request xmlns="">
      <scenario_name>{scenario_name}</scenario_name>
      <id_no>{dg.selectedItem.id}</id_no>
      <region_name>{dg.selectedItem.region_name}</region_name>
      <population>{dg.selectedItem.population}</population>
      <market>{dg.selectedItem.market}</market>
      </mx:request>
      </mx:HTTPService>
        • 1. How to Make SelectedItem be a Dynamic Variable?
          *gsb*
          Hummm....

          I think you need to view the problem in steps.
          First I think you need to update one record at a time.

          So when a row is clicked on, it pops up an edit form.
          When submitted (button perhaps) it updated the data provider of the data grid: instant show of the change.
          At the same time, an HTTP service call is made to update the data base. There is no need to update the application with the new data from the server.

          Now back on the data grid the user can pick another record to update.

          Buttons could be added for Add, Delete and use click for Edit perhaps.

          EDIT: BTW - I use PHP on the server to save (re-save) the XML data base file.
          • 2. Re: Update Multiple Rows at Once in the Database
            Level 7

            "alice_data" <webforumsuser@macromedia.com> wrote in message
            news:ggen1o$a3c$1@forums.macromedia.com...
            > Hi,
            >
            > My client wanted me to create something that allows certain DataGrid to
            > display to allow users to edit and update the database records. The only
            > dilemma I am having here is how to actually create something from Flex's
            > end to
            > allow users update several rows of the database at once. Since everything
            > in my
            > datagrid would be defined as selectedItem whenever a user accesses the
            > entry,
            > how can I get Flex to recognize each of the updated variables while I
            > update
            > the database?

            Add like an updated property to each item in the collection. Then set it
            when the user has changed something. Then filter the collection to items
            that have been updated and send them to the server.


            • 3. How to Make SelectedItem be a Dynamic Variable?
              alice_data Level 1
              Hi,

              My dataGrid is editable in the first place, since there are not that many things in need of a new form. As one of the members who have been informing, I am planning on using this with PHP, and the PHP code has been written up, and I have tested this using a "form" entry format instead of calling it from Flex, it seems to be working.

              So, I think one of things I have to find out is how to pass the variables on to the HTTPService, When I declare the variable, dg.itemindex.item_element_name, is this how I should declare my variables that loop around for the PHP to process?

              Thanks in advance.

              Alice