5 Replies Latest reply on Apr 11, 2008 6:41 PM by peterskeeter

    Datagrid Array Problem

    ca895680
      Hello to everyone who reads this. I've been on the forums over the past few days trying to track down my issue, but I cant seem to nail it down. I was hoping someone would have the time to help me out.

      Problem is this: Play list editor what all the information is stored in a mysql database. retrieving the information and passing it to flex and working with it in data grids has been relatively smooth. The problem happens when I attempt to drag files onto the playlist. It seems the information being passed is an array 'items' as it states in the docs, but in each array is xml associated with the file.

      ex:
      <file>
      <FK_File>752</FK_File>
      <filename>01 Summertime.mp3</filename>
      <filePath>/home/public/data/audio/Internal HDD-CORE (sda1) [42]/Various Artists/Summertime</filePath>
      <pic> http://dcerouter/pluto-admin/mediapics/5153_tn.jpg</pic>
      <Title>Summertime</Title>
      <genre PK_Attribute="73">Funk</genre>
      <performer PK_Attribute="308">Ohio Players</performer>
      <ReleaseDate PK_Attribute="229">2005</ReleaseDate>
      <Album PK_Attribute="311">Summertime</Album>
      <Track PK_Attribute="72">1</Track>
      </file>
      ,
      <file>
      <FK_File>1426</FK_File>
      <filename>02 Fantasy.mp3</filename>
      <filePath>/home/public/data/audio/Internal HDD-CORE (sda1) [42]/Earth, Wind &amp; Fire/Earth Wind &amp; Fire</filePath>
      <pic> http://dcerouter/pluto-admin/mediapics/270_tn.jpg</pic>
      <Title>Fantasy</Title>
      <genre PK_Attribute="73">Funk</genre>
      <performer PK_Attribute="762">Earth Wind &amp;amp; Fire</performer>
      <ReleaseDate PK_Attribute="765">1978</ReleaseDate>
      <Album PK_Attribute="766">Earth Wind &amp;amp; Fire</Album>
      <Track PK_Attribute="151">2</Track>
      </file>
      ,
      <file>
      <FK_File>1974</FK_File>
      <filename>02 Give Up The Funk (Tear The Roof Off The Sucker).mp3</filename>
      <filePath>/home/public/data/audio/Internal HDD-CORE (sda1) [42]/Parliament/Tear The Roof Off 1974-1980 (Disc 2)</filePath>
      <pic> http://dcerouter/pluto-admin/mediapics/_tn.jpg</pic>
      <Title>Give Up The Funk (Tear The Roof Off The Sucker)</Title>
      <genre PK_Attribute="73">Funk</genre>
      <performer PK_Attribute="1150">Parliament</performer>
      <ReleaseDate PK_Attribute="731">1976</ReleaseDate>
      <Album PK_Attribute="1153">Tear The Roof Off 1974-1980 (Disc 2)</Album>
      <Track PK_Attribute="151">2</Track>
      </file>

      Im assuming the comma separation from each child 'file', denotes the items are stored as an array. i don't know if i should attempt to send them back to php for processing of if im doing something wrong to begin with that the data comes out that way.

      Thanks in advance for any responses or insights.
        • 1. Re: Datagrid Array Problem
          peterskeeter Level 1
          so can you restate what the exact problem is. It looks like your data
          is successfully coming back from mysql (via php script) ??
          Cant you access the returned xml now and just process it in actionscript ?
          • 2. Re: Datagrid Array Problem
            ca895680 Level 1
            Hello Peterskeeter,

            the data is in fact being returned via a php script. for the update mysql query, i dont need xml, just the data contained in the selected nodes. However the "items" array returns an the xml node for the entire object selected row (see example in original post) and i'm not sure how to just get the data sans XML markup. Am i making sense or am I going about this all wrong?
            • 3. Re: Datagrid Array Problem
              peterskeeter Level 1
              So is what your doing similar in logic to this
              http://www.adobe.com/devnet/flex/quickstart/adding_drag_and_drop/
              go right to the bottom of the page where they drag and drop the coins
              into the box and the box adds up the money.
              See how they only add the cents value to the dragsource..

              dragSource.addData(value, 'value');

              If you only add the items your after in your code ?
              I cant see explicitly where you are doing this so I assume theres a default (the whole lot) gets added ..

              Can I ask, is there an over riding reason why your using xml... i personally tend to avoid it if i can..I know I've had to use it before to populate menu bars in flex.. I see the resultformat from some of your httpservice calls are in e4x..so I assume your php / db deals in xml too...
              • 4. Datagrid Array Problem
                ca895680 Level 1
                Thanks for another fast response!

                After reading through the docs, i found they had special pre-names variables for list controls and datagrids. So when you drag, it automatically adds the items selected into an array called "items". my problem was that it was an xml string instead of what I thought would be a proper array. Since your message earlier today, I decided to just handle the array with some processing in php, essentially solving the problem although I would prefer not having so much time to handle xml.

                As for the reason im using XML, I a newbie at flex and generally stay away from XML. There is no requirement to USE XML other than I though it would be an easier method of transporting data in between flex and php.

                I am working with a fairly large DB with keys all over the place. I pull them all into one cohesive array, convert it to xml and send it to flex. I originally tried using the array itself, but my beginnerness (not a word i know) kinda prodded me to the easier route. Please feel free to send me in a proper direction as this is all very new to me. I've been working with php/mysql for a little over a year now and flex is brand new.
                • 5. Re: Datagrid Array Problem
                  peterskeeter Level 1
                  I'm not sure there is a proper way to do anything ( who decides this anyhow :) ) ....I guess it depends on what your doing and how efficient it is and whether it needs to scale to a massive system or not..otherwise if it works ...it works !
                  I dont actually use php on the server side, i use java remote objects. and they return java collections...which i then cast to arraycollection in flex and access it that way...I'm not sure what the php equivalent is, some sort of array (cohesive ??) as you mentioned. I really like the way java and flex co-exist on the server & client. If i make a .as class for an object in flex, I then make the equivalent java class on the server so I can store it in the DB
                  and do the CRUD stuff. I use keys a lot too, so i find my datagrids in flex often need itemrenderers / comboboxes to be able to choose the key values as options , so the combo items come straight out the DB too..anyway you get the gist..it sounds like your doing similar. I have done a little php before and I really liked how little code was required to do stuff. I think for me, I've done a bit of java before so its easier just to stay with what you know..glad you sorted it out yourself too.