Does 2.1 Fix the random field ordering?

680
8
09-23-2010 07:29 AM
TonyCollins
Occasional Contributor
Hi there,

Does 2.1 Fix the random field ordering issue when performing an identify? I have just had a call closed which I need to reopen if this is not the case!

I have just tested it, and although it looks a different order to my production application it still does not list the fields in the same order as the dataset.

Can anyone give me some direction as this is something that is getting logged with me regularly as new users migrate to this system.
Tags (2)
0 Kudos
8 Replies
SallyGracia
New Contributor II
Hi there,

I reported the same issue this week in 2.0. Not sure if it is fixed in 2.1. It's weird that the data displays in a random order.
0 Kudos
DasaPaddock
Esri Regular Contributor
The order of the fields shown in the Search and Query widgets is undetermined if you return all the fields using all="true" and you're not using ArcGIS Server 10.
0 Kudos
TonyCollins
Occasional Contributor
The order of the fields shown in the Search and Query widgets is undetermined if you return all the fields using all="true" and you're not using ArcGIS Server 10.



Does this apply when using an IdentifyTask?
0 Kudos
DasaPaddock
Esri Regular Contributor
No, you'd still need to either hard-code or use LayerDetails.fields to pull out the attributes in a particular order. The Search and Query Widgets are taking advantage of the fields returned as part of the FeatureSet from ArcGIS Server 10. Here's the code from QueryWidget:

                        if (featureSet.fields) // requires ArcGIS Server 10.0+
                        {
                            for each (var field:Field in featureSet.fields)
                            {
                                if (field.name in graphic.attributes)
                                {
                                    displayFields(field.name, getFieldXML(field.name), field);
                                }
                            }
                        }
                        else
                        {
                            for (var fieldName:String in graphic.attributes)
                            {
                                displayFields(fieldName, getFieldXML(fieldName), null);
                            }
                        }


The underlying problem is that when you use for..in statements to pull out all the values from an Object, ActionScript doesn't guarantee any order.

Reference:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html#for..in
0 Kudos
TonyCollins
Occasional Contributor
No, you'd still need to either hard-code or use LayerDetails.fields to pull out the attributes in a particular order. The Search and Query Widgets are taking advantage of the fields returned as part of the FeatureSet from ArcGIS Server 10. Here's the code from QueryWidget:

                        if (featureSet.fields) // requires ArcGIS Server 10.0+
                        {
                            for each (var field:Field in featureSet.fields)
                            {
                                if (field.name in graphic.attributes)
                                {
                                    displayFields(field.name, getFieldXML(field.name), field);
                                }
                            }
                        }
                        else
                        {
                            for (var fieldName:String in graphic.attributes)
                            {
                                displayFields(fieldName, getFieldXML(fieldName), null);
                            }
                        }


The underlying problem is that when you use for..in statements to pull out all the values from an Object, ActionScript doesn't guarantee any order.

Reference:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html#for..in


Hi Dasa, Thanks for your replies on this and sorry if this sounds like me just trying to get my head round it!

I understand what you say about looping through dynamic object properties, but when I look at a feature within an IdentiftResult the attributes are all in a seemingly random order before I do any for..in statements?

As the tool in question is an Identify it is used on any service layer and I will therefore not know what data to expect so hard-coding is not an option for me.

So in short (for my boss), IdentifyResult.Feature.Attributes are always going to be in a random order until we move to ArcGIS Server 10?

Thanks for you help, I just need to be able to say this issue will definitely be addressed when we upgrade and do a little recoding.


Side note: I'm not using the viewer or any widgets.
0 Kudos
DasaPaddock
Esri Regular Contributor
I understand what you say about looping through dynamic object properties, but when I look at a feature within an IdentiftResult the attributes are all in a seemingly random order before I do any for..in statements?

What are you using to "look at a feature"?

So in short (for my boss), IdentifyResult.Feature.Attributes are always going to be in a random order until we move to ArcGIS Server 10?

This is not changed by AGS 10 since the attributes are still in an object. You can use LayerDetails to get the fields of the layer and loop through them in that order like the code above in the QueryWidget.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/supportClasses/LayerDetails.html
0 Kudos
TonyCollins
Occasional Contributor
What are you using to "look at a feature"?


This is not changed by AGS 10 since the attributes are still in an object. You can use LayerDetails to get the fields of the layer and loop through them in that order like the code above in the QueryWidget.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/supportClasses/LayerDetails.html


Looking in a debug session ....

So LayerDetails in v10 is the answer?

Thanks again
0 Kudos
DasaPaddock
Esri Regular Contributor
Yes, except ArcGIS Server 10 is not required to get LayerDetails (unless you're trying to get them all at once in the AllDetails class).
0 Kudos