This content has been marked as final. Show 7 replies
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.
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.
Thank you for the reply.
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.
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?
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:
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?
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.
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.