<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Sorting IdentifyWidget attribute display order in ArcGIS Viewer for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/sorting-identifywidget-attribute-display-order/m-p/441819#M12668</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A question was posted on the IdentifyWidget comments board about sorting the display order of the returned attributes. If you don't mind modifying code, this is an easy change to make.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that this only affects the order of attributes for layers not explicitly defined in the IdentifyWidget.xml file. Layers which are defined in the config XML will have their attributes displayed in the order that they are defined in the fields list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the onResult function of the IdentifyWidget.mxml, locate the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for (fld in obj){
 try{
&amp;nbsp; value = obj[fld] ? String(obj[fld]) : "";
 } catch (error: Error) {
&amp;nbsp; value = "";
 }
 value = value.replace(/&amp;gt;/g,"&amp;amp;gt;").replace(/&amp;lt;/g,"&amp;amp;lt;");
 content += "&amp;lt;b&amp;gt;" + fld + ":&amp;nbsp; &amp;lt;/b&amp;gt;"+ value + "&amp;lt;br&amp;gt;";
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change it to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
var fldArray:ArrayCollection = new ArrayCollection();

for (fld in obj){
 try{
&amp;nbsp; value = obj[fld] ? String(obj[fld]) : "";
 } catch (error: Error) {
&amp;nbsp; value = "";
 }
 value = value.replace(/&amp;gt;/g,"&amp;amp;gt;").replace(/&amp;lt;/g,"&amp;amp;lt;");
// content += "&amp;lt;b&amp;gt;" + fld + ":&amp;nbsp; &amp;lt;/b&amp;gt;"+ value + "&amp;lt;br&amp;gt;";
 // Instead of just printing out the fields as they appear, add
 // them to an array so they can be sorted.
 fldArray.addItem({name:fld, value:value});
}

// Sort the attributes
var sortField:SortField = new SortField("name"); // alpha, asc
var sort:Sort = new Sort();
sort.fields = [sortField];
fldArray.sort = sort;
fldArray.refresh();
var cur:IViewCursor = fldArray.createCursor();
while (!cur.afterLast) {
&amp;nbsp; content += "&amp;lt;b&amp;gt;" + cur.current.name + ":&amp;nbsp; &amp;lt;/b&amp;gt;"+ cur.current.value + "&amp;lt;br&amp;gt;";
&amp;nbsp; cur.moveNext();
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Dec 2012 21:31:04 GMT</pubDate>
    <dc:creator>NicholasRanicar</dc:creator>
    <dc:date>2012-12-10T21:31:04Z</dc:date>
    <item>
      <title>Sorting IdentifyWidget attribute display order</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/sorting-identifywidget-attribute-display-order/m-p/441819#M12668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A question was posted on the IdentifyWidget comments board about sorting the display order of the returned attributes. If you don't mind modifying code, this is an easy change to make.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that this only affects the order of attributes for layers not explicitly defined in the IdentifyWidget.xml file. Layers which are defined in the config XML will have their attributes displayed in the order that they are defined in the fields list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the onResult function of the IdentifyWidget.mxml, locate the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for (fld in obj){
 try{
&amp;nbsp; value = obj[fld] ? String(obj[fld]) : "";
 } catch (error: Error) {
&amp;nbsp; value = "";
 }
 value = value.replace(/&amp;gt;/g,"&amp;amp;gt;").replace(/&amp;lt;/g,"&amp;amp;lt;");
 content += "&amp;lt;b&amp;gt;" + fld + ":&amp;nbsp; &amp;lt;/b&amp;gt;"+ value + "&amp;lt;br&amp;gt;";
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change it to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
var fldArray:ArrayCollection = new ArrayCollection();

for (fld in obj){
 try{
&amp;nbsp; value = obj[fld] ? String(obj[fld]) : "";
 } catch (error: Error) {
&amp;nbsp; value = "";
 }
 value = value.replace(/&amp;gt;/g,"&amp;amp;gt;").replace(/&amp;lt;/g,"&amp;amp;lt;");
// content += "&amp;lt;b&amp;gt;" + fld + ":&amp;nbsp; &amp;lt;/b&amp;gt;"+ value + "&amp;lt;br&amp;gt;";
 // Instead of just printing out the fields as they appear, add
 // them to an array so they can be sorted.
 fldArray.addItem({name:fld, value:value});
}

// Sort the attributes
var sortField:SortField = new SortField("name"); // alpha, asc
var sort:Sort = new Sort();
sort.fields = [sortField];
fldArray.sort = sort;
fldArray.refresh();
var cur:IViewCursor = fldArray.createCursor();
while (!cur.afterLast) {
&amp;nbsp; content += "&amp;lt;b&amp;gt;" + cur.current.name + ":&amp;nbsp; &amp;lt;/b&amp;gt;"+ cur.current.value + "&amp;lt;br&amp;gt;";
&amp;nbsp; cur.moveNext();
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 21:31:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/sorting-identifywidget-attribute-display-order/m-p/441819#M12668</guid>
      <dc:creator>NicholasRanicar</dc:creator>
      <dc:date>2012-12-10T21:31:04Z</dc:date>
    </item>
  </channel>
</rss>

