6 Replies Latest reply on Oct 31, 2008 12:49 PM by MacGyverMan

    Working with Flat data from DB

    MacGyverMan Level 1
      I have data coming into flex via a remote AMFPHP object. The data is basically an array containing generic objects
      [0]
      date, entry, grade, class, type, db_ID, language etc...
      [1]
      date, entry, grade, class, type, db_ID, language etc...
      ...

      I want the user to be able to edit individual entries, mark them for update, delete or insert and then synch with the DB.

      The problem:
      The user must be able to class the data according to:
      =DATE 1
      .....=GRADE 1
      .........=CLASS 1
      .............=TYPE 1
      .................ENTRY 1
      .................ENTRY 2
      .............=TYPE 2
      .................ENTRY 1
      .................ENTRY 2
      .........=CLASS 2
      .............=TYPE 1
      .................ENTRY 1
      .................ENTRY 2
      .............=TYPE 2
      .................ENTRY 1
      .................ENTRY 2

      And so on.

      Obviously the control the lends itself to this is the AdvancedDataGrid?? However, editing seems tricky since there doesn't seem to be an easy way to ADD / Delete entries from the dataprovider. (Keep in mind the source array is first filtered for the correct dates, then grouped to form the hierarchy).

      Right now: ADDING to the DP works, however the entry can't be selected once it's inserted.
      Right now: DELETING to the DP might work, but I can't find a way to insert a delete button beside each entry.


      So, finally, my question is:
      Is there a better control that lends itself to this problem?
      I've thought of using various comboboxes to allow the user to pick the day, class, subject, type and then run the filterfunction. However, I can't find a way to traverse my source data to get a list of the possible values to put into the combo boxes.

      Thanks for anyhelp.
        • 1. Re: Working with Flat data from DB
          Gregory Lafrance Level 6
          May be best to return the data as XML, then you can easily put it in ComboBoxes or ADG. The data format always makes life easy or hard.
          • 3. Re: Working with Flat data from DB
            Level 7

            "MacGyverMan" <webforumsuser@macromedia.com> wrote in message
            news:geb33g$14j$1@forums.macromedia.com...
            >I have data coming into flex via a remote AMFPHP object. The data is
            >basically
            > an array containing generic objects
            > [0]
            > date, entry, grade, class, type, db_ID, language etc...
            > [1]
            > date, entry, grade, class, type, db_ID, language etc...
            > ...
            >
            > I want the user to be able to edit individual entries, mark them for
            > update,
            > delete or insert and then synch with the DB.
            >
            > The problem:
            > The user must be able to class the data according to:
            > =DATE 1
            > .....=GRADE 1
            > .........=CLASS 1
            > .............=TYPE 1
            > .................ENTRY 1
            > .................ENTRY 2
            > .............=TYPE 2
            > .................ENTRY 1
            > .................ENTRY 2
            > .........=CLASS 2
            > .............=TYPE 1
            > .................ENTRY 1
            > .................ENTRY 2
            > .............=TYPE 2
            > .................ENTRY 1
            > .................ENTRY 2
            >
            > And so on.
            >
            > Obviously the control the lends itself to this is the AdvancedDataGrid??
            > However, editing seems tricky since there doesn't seem to be an easy way
            > to ADD
            > / Delete entries from the dataprovider. (Keep in mind the source array is
            > first
            > filtered for the correct dates, then grouped to form the hierarchy).
            >
            > Right now: ADDING to the DP works, however the entry can't be selected
            > once
            > it's inserted.

            Have you issued an itemUpdated() on the collection where the item is?

            > Right now: DELETING to the DP might work, but I can't find a way to insert
            > a
            > delete button beside each entry.

            Just add a property to each object "toDelete" or something, and make an
            additional column to hold it. Or you could do something like this:
            http://blog.flexmonkeypatches.com/2007/09/10/flex-tilelist-with-togglebuttons/

            > So, finally, my question is:
            > Is there a better control that lends itself to this problem? I've thought
            > of
            > using various comboboxes to allow the user to pick the day, class,
            > subject,
            > type and then run the filterfunction. However, I can't find a way to
            > traverse
            > my source data to get a list of the possible values to put into the combo
            > boxes.

            Recursion is a PIA. You might want to look at this component for an idea of
            an approach
            http://www.quietlyscheming.com/blog/components/randomwalk-component/


            • 4. Re: Working with Flat data from DB
              MacGyverMan Level 1
              Thanks for the help guys.

              So am I really better to use XML? I assumed a binary format would be much more efficient...however I can't stand/understand how flex handles bindings and multidimentional arrays. I wish it were as simple as PHP multimentional hash-arrays.

              Thanks for the suggestion to use itemUpdated, however it doesn't seem to change anything. I don't think it's an issue of the arraycollection not knowing of the changes since the changes should not affect the item's display...I suspect it has something to do with the ADG's itemRenderers not beeing generated properly due to the addition of an extra item.
              • 5. Re: Working with Flat data from DB
                Level 7

                "MacGyverMan" <webforumsuser@macromedia.com> wrote in message
                news:gedmtj$pcg$1@forums.macromedia.com...
                > Thanks for the help guys.
                >
                > So am I really better to use XML? I assumed a binary format would be much
                > more
                > efficient...however I can't stand/understand how flex handles bindings and
                > multidimentional arrays. I wish it were as simple as PHP multimentional
                > hash-arrays.
                >
                > Thanks for the suggestion to use itemUpdated, however it doesn't seem to
                > change anything. I don't think it's an issue of the arraycollection not
                > knowing
                > of the changes since the changes should not affect the item's display...I
                > suspect it has something to do with the ADG's itemRenderers not beeing
                > generated properly due to the addition of an extra item.

                Is it possible that's a problem in your itemRenderer code?


                • 6. Re: Working with Flat data from DB
                  MacGyverMan Level 1
                  I thought so, but I got rid of the custom renderer.

                  Dammit...I wish I could post the SWF to show what happens...however it's running of amfphp on a local server