7 Replies Latest reply on Jul 15, 2008 5:04 PM by Petril21

    making a datagrid display properly

    Petril21
      I am looking for an easy solution to make the datagrid display correctly. I would assume there is a way to display the data in the order of the xml document that is being loaded. Why would the component disregard the file it is sent, doing extra work, just to make it display in the wrong order? If I send XML with the product ID first and the cost second, why should cost come first? Is there any simple way to get around this maddnes (or do other programmers think that losing control over display logic is cool?).

      Sorry if this seems jaded, but I have been looking for answer for quite a while. I have tried adding datagridcolumns to the datagrid object with no luck, etc. I don't see a solution will someone please help?

      Even if there is no solution, would someone at least comment and say so, the last post I made about this had no one helping either way. Please HELP!!!!
        • 1. Re: making a datagrid display properly
          ntsiii Level 3
          Yes, there is a very simple answer.

          Declare your columns explicitly, using mx:DataGridColumn

          Or, build the DataGrid columns programatically. I have an example on www.cflex.net of that.

          Tracy
          • 2. Re: making a datagrid display properly
            ntsiii Level 3
            Also, just guessing here, but I bet you have not set your resultFormat="e4x', or are using mx:Model.

            Are either of those true? Either one will result in the datagrid having to use an Array, and Array order is not reliable in AS or any ECMA language. Usually it is the reverse of the order which the elements are added, but that is not necessarily reliable.

            DataGrid is not doing "extra work" to make your column order "wrong". There is just more happening than you realize.

            Tracy
            • 3. Re: making a datagrid display properly
              Petril21 Level 1
              Thank you for the reply.

              http://www.cflex.net/showFileDetails.cfm?ObjectID=552

              that should work perfectly! thank you.

              >>DataGrid is not doing "extra work" to make your column order "wrong".
              >> There is just more happening than you realize.
              I guess I just don't understand why it won't just display in the order it is given.

              Is there a reason that it doesn't just go node by node adding the data? I seems to me like it would have to take an extra step to alphabetize the data, before rendering the datagrid. In my case at least this seems like a feature that is getting in the way.

              btw, I am not using resultFormat or model component.
              • 4. Re: making a datagrid display properly
                ntsiii Level 3
                If you are not setting resultFormat="e4x" then you are not working with XML. Flex is converting your xml into a nested object structure.

                But I am confused now. Are you talking about colulmn order or row order?

                Tracy
                • 5. Re: making a datagrid display properly
                  Petril21 Level 1
                  I understand that the data is coming back as an object proxy, but it goes into the dataProvider the same(or such is my assumption).

                  I am talking about the column order. If I feed this as a church bus schedule:

                  <joblist>
                  <joblistitem>
                  <date>12-12-08</date>
                  <story>Amy</story>
                  <preach>Nathan</preach>
                  <cleanbus>Garry</cleanbus>
                  </joblistitem>
                  ...
                  </joblist>
                  and have everything in the same order, I don't want <cleanbus> column to be before the <date> column.

                  I should get columns :
                  date | story | preach | cleanbus

                  I know I can hard code the columns, but there may be someone entering the jobs in a different order, or have different names for the jobs, or have different jobs all together. They may even prefer to have <week> or <Sunday> instead of <date>.

                  I tried using that code on the link : http://www.cflex.net/showFileDetails.cfm?ObjectID=552
                  but am having some type casting problems, just seems like there would be a simpler way doesn't it?
                  • 6. Re: making a datagrid display properly
                    ntsiii Level 3
                    Using the default resultFormat means you are dealing with Objects and Arrays, not XML, and Array order is not reliable as I mentioned previously. The dataGrid is not alphabetizing the column order, it is reading it out of the array that the default xml de-serializer builds.

                    You might try it with true XML, that is more likely to preserve the order.

                    Tracy
                    • 7. Re: making a datagrid display properly
                      Petril21 Level 1
                      I have tried it using e4x, array, and the default value (object proxy). Non eof which presrve the order. I have the complete solution for what I need. I just used the link that you provided as a guide and am creating datagrids and columns through actionscript. I can post what I have if anyone else is having this problem, or is curious.

                      Thanks for you help Tracy.