3 Replies Latest reply on Oct 26, 2006 8:09 AM by rmarp

    Problem: Array to datagrid

      Hey Guys,

      I got a problem getting an array into a Datagrid.

      My XML
      quote:


      ..
      <uitvoering>
      <naam>Hocker</naam>
      <hoogte>40</hoogte>
      <breedte>61</breedte>
      <diepte>57</diepte>
      <stof>
      <naam>Nevada</naam>
      <prijs>169</prijs>
      </stof>
      <stof>
      <naam>Sirius</naam>
      <prijs>169</prijs>
      </stof>
      .. (more)



      If i put this into a Datgrid it comes out as the following

      [Key-naam] ---- [Key-hoogte] ---- [Key-breette] ...
      Value-naam---- Value-hoogte----Value-breette...
      Value-naam---- Value-hoogte----Value-breette...
      ... lots more :P

      Wich is good for one of the views i have to make but for the second one i have to do something quite difficult, in my eyes at least . I want the second view to look like this.

      [Key-naam] ---- [ Value-stof.naam 1] ---- [ Value-stof.naam 2] ...
      Value-naam----Value-stof.prijs 1-----------------Value-stof.prijs 2-----------...
      ..lots more

      I kept the original key names altho there in Dutch but the structure is in the quote above, I hope you get the idea, its rather hard to make a nice grid :)

      But is this even possible in flex? if it is can somebody please give me an example or a link to a page with a tutorial or something like that!

      Thanks in advance!
        • 1. Re: Problem: Array to datagrid
          rmarp
          Can you post the code you are using so we can see exactly how you are passing to the datagrid?

          Ryan
          • 2. Re: Problem: Array to datagrid
            sue no problem:

            I load my xml like this :

            <mx:HTTPService id="modelSpecs" url="modellen.xml" useProxy="false" />

            then i open a datagrid an give it a provider

            <mx:DataGrid x="10" y="10" id="dgPosts" width="562" height="473" dataProvider="{modelSpecs.lastResult.model.uitvoering}">
            </mx:DataGrid>

            And this works fine for the first method!, but i truely have no idea how to get it like the second example i posted.

            ideas anyone?
            • 3. Re: Problem: Array to datagrid
              rmarp Level 1
              Ah now I see what you are trying to do. You're basically trying to have the datagrid navigate down into various levels of the xml. I think you're going to have to do some processing on the xml before passing it to the datagrid. Maybe you can create a new xml document based on the original. I believe the datagrid is only going to work on the xml nodes and values attached directly to that node, not underneath it.
              1 person found this helpful