Selection Widget Updated Version

42365
146
05-12-2011 05:24 AM
MarkHoyland
Occasional Contributor II
The Selection widget has a "Select by Attributes" and "Select by Location" option similar to ArcGIS.
Widget link: http://www.arcgis.com/home/item.html?id=20ed6af9ab204548bbf092d51b51fef8

Version 1.5 of the widget replaces version 1.0

Enhancements and fixes include:
*Each time a query layer was added it was also being added to the TOC. This has been fixed.

*When resizing the widget, the datgrid would not resize properly. This has been fixed.

*Uses paging for selection of unique value list. This means that ALL values will be parsed regardless of the ArcGISServer setting to limit responses. There is an option to ESC out of a large query. (This is only for the Unique list, not getting features).
I have included an ESRI TaxParcel Layer that has 18,000+ records. Get Unique Values on the PSTLSTATE field to see this in action.
Available on my example site. The URL is on the Widget download page.

*Aliases can now be used. It will now use the Alias as set in the Featureclass. You can also override the Alias in the SelectionWidget.xml config file.

*ArcGis layers that have joined tables will now work with fully qualified field names. (thanks Dasa for the idea)

*Styling for selection colours has been documented in the SelectionWidget.xml config file (example provided).

*Styling for datagrid has been changed. It can now also be styled in SelectionWidget.xml config file (example provided). (thanks Mehul for the idea)

*Changed initial uniquevalue query to use "text='%'" instead of "where '1=1'" for Mike.:)

*You can now override scale range for layers.

*Link field now has a prefix/suffix option in the SelectionWidget.xml config file (naming convention the same as Robert SCheitlin's esearch widget)

*Shape_area and Shape_length can be used in the fields.

Link to previous thread :http://forums.arcgis.com/threads/24151-Selection-Widget-for-SFV2.2-(with-a-query-builder)
Tags (2)
0 Kudos
146 Replies
NickDeMerchant
New Contributor
Great widget Mark.

To quote Mark

"Is there anyway to have date values in the unique values box formated as dates, rather than the numbers that are actually stored? "

For example :
<format dateformat="shortDate"/>
or
dateformat="MM/DD/YYYY" 

Thanks,

Nick
0 Kudos
deleted-user-RjoC4IOGTpoH
New Contributor
Good Morning,

When compiling the widget, I get the following warnings:

In SelectByAttributes.mxml at lines 317 & 318 "Data binding will not be able to detect assignments to "length"."

In SelectionResults.mxml at lines 313, 318 & 323 "Data binding will not be able to detect assignments to "length"."

Also, is there a way to select what fields are displayed on the popup window when you hover over the selection? In the infowindow I need to see the data for all the fields but not in the popup window.

I am on Server 10, SP3, Viewer 2.4

Thanks and a great app.

Nestor.
0 Kudos
HaroldBostic
Occasional Contributor II
To fix the issue with the date being represented by it's UTC decimal equivalent (I think), make the following changes on the SelectionResults.mxml file under components

add-> import mx.formatters.DateFormatter;

add ->
private function dateLabel(fullfieldname:String):Function {
    return  function (item:Object, column:DataGridColumn):String { 
     
     var dateFormatter:DateFormatter  = new DateFormatter ();
     dateFormatter.formatString = "MM/DD/YYYY";
     
     return dateFormatter.format(new Date(item[fullfieldname]));
    };
   }


modify->dgColumn.labelFunction = labelOf(fld.name);

change to -> dgColumn.labelFunction = fld.type == "esriFieldTypeDate" ? dateLabel(fld.name) : labelOf(fld.name);

you may want to have the formatter as a resource rather than create it in the function, either way this should fix that issue.  Let me know if there are further refinements to this fix
0 Kudos
AlanHammersmith
New Contributor III
Hello,

Thank you very much for this widget!  I love the flexibility it provides.  However, I am experiencing a couple problems.  When I setup the widget, at first it looks great when I run a query, and when I hover over the data grid with all graphics in view, the info windows work as expected.  As soon as I click on a row in the data grid, it zooms into that feature, as expected.  However, whenever I hover over another item in the data grid, the popup for the feature I just zoomed to gets updated with the data from the feature I am hovering over.  A similar thing happens when I click on a row at the bottom of the data grid.  The map zooms to that feature, but the grid resets itself so the first records is displayed (ie-scrolls back to the top), but now my mouse is hovering over a different feature than I just clicked on, so the info window displays data from the feature I'm hovering over and not the one I just clicked on.

Any thoughts?  I'm using ArcGIS 10.0 SP3 and FV 2.4.

Thanks,
Alan
0 Kudos
H_JamesWorley_III
New Contributor
I am having a devil of a time to get this widget to work. There is a spinning clock that spins to infinity and no values are coming in. This widget is exactly what we need. I am running Flash Builder 4.5 and Flex Viewer 2.4. Any help would be appreciated.
0 Kudos
AineMc_Alister
New Contributor
Hi Mark I am after some advice I have listed my layers in alphabetical order within the SelectionWidget.xml file however they don't always appear listed in alphabetical order in the viewer (FlexViewer 2.3). Do you have any idea how I would resolve this? How should I sequence the layers in the widget? Any information would be much appreciated.
0 Kudos
LeeSheau_Wei
New Contributor II
Hi,

Is that got someone already recompiled the Selection Widget to flex viewer 2.4?

Thanks,
Sheau Wei
0 Kudos
ChrisNorth
Esri Contributor
Hi Harold,

Thanks for this - it works great in the results data grid - can you suggest where the similar fix should go in the sample values?  In the selction query builder interface, date values for a date field still appear as the UTC decimals.

Thanks,
Chris
0 Kudos
AngieAllison
New Contributor II
Does anyone have a compiled fix for the date issue?  it is showing some long number for the date??
0 Kudos
HaroldBostic
Occasional Contributor II
Hi Harold,

Thanks for this - it works great in the results data grid - can you suggest where the similar fix should go in the sample values?  In the selction query builder interface, date values for a date field still appear as the UTC decimals.

Thanks,
Chris


Sorry for the late response, what you want to do is the following:
In utils\PagingQueryTask

add -> import mx.formatters.DateFormatter;

replace the function getDistinct Values with this function:
private function getDistinctValues(array:Array, fieldName:String, fieldType:String=""):Array 
  {
   //prepare result array
   var collection:ArrayCollection = new ArrayCollection(array);
   var distinctValuesCollection:ArrayCollection = new ArrayCollection();
   
   //prepare a temp working array
   var tempPropertyArray:Array = [];
   
   //loop over all the objects in the collection
   for each (var object:Object in collection) {
    //get the value from the object
    var propertyValue:Object
    // check the data type, add '' quotes if needed.
    if (fieldType == 'esriFieldTypeString' ||
     fieldType == 'esriFieldTypeGUID' ) 
    {
     
     propertyValue = "'" + object[fieldName] + "'";
    }
    else if(fieldType == 'esriFieldTypeDate')
    {
     var dateFormatter:DateFormatter  = new DateFormatter ();
     dateFormatter.formatString = "MM/DD/YYYY";
     propertyValue = "'" + dateFormatter.format(new Date(object[fieldName])) + "'";
    }
    else
    {
     propertyValue = object[fieldName];
    }
    //write the value as a property. If it exists it will be overwritten
    //which creates a distinct list
    tempPropertyArray[propertyValue] = true;
   }
0 Kudos