Select to view content in your preferred language

Enhanced-Search-Widget-for-FlexViewer Part III

179997
776
04-30-2013 03:58 PM
RobertScheitlin__GISP
MVP Emeritus
All,

   Here is a new thread to post questions and discuss the Enhanched Search Widget. The old thread was getting too long.
Tags (2)
776 Replies
RobertScheitlin__GISP
MVP Emeritus
David,

   Yes there has been some issue with Subtype and how ArcGIS Server is returning field names in the wrong CaSe and with flex being a case sensitive language this is an issue but I though I have applied a work around in the code... Can you provide a screen shot(s) of your WHOLE Rest Service directory page for that layer and your eSearchWidget.xml (that is if your services and viewer are not public)?
0 Kudos
DavidColey
MVP Frequent Contributor
Hey Robert, sure thing.  I am going to go ahead and un-secure this service:

https://ags2.scgov.net/arcgis/rest/services/ScOperational/SCDataAgol/MapServer
and then let's work with the Parks layer at:
https://ags2.scgov.net/arcgis/rest/services/ScOperational/SCDataAgol/MapServer/25
If that's ok with you.  I can leave it unsecure throughout the day oon 7/11/2013

The subtype field is 'ParkType', the 'PublicAccess' field has the coded domain values.  I am not utilizing the coded domain field as as a search, but am returning its values.  Perhaps it is the fact that these domain values are inherited?
Thanks, looking forward to your reply--

Here is my full layer xml section for this layer:

<layer>
     <token/>
  <useproxy>false</useproxy>
  <definitionexpression></definitionexpression>
  <enableprintgrid title="Selected Parks">true</enableprintgrid>
  <enableexport>true</enableexport>
        <name>Sarasota County Parks</name>
  <url>https://ags2.scgov.net/arcgis/rest/services/ScOperational/SCDataAgol/MapServer/25</url>
  <expressions>
   <expression alias="Park Type" textsearchlabel="Search by Park Type:" isvaluerequired="false">
    <values>
     <value prompt="Example: Natural Area Park" field="ParkType" usesubtype="true">ParkType = [value]</value>
    </values>
   </expression>
   <expression alias="Park Name" textsearchlabel="Search by Park Name:" isvaluerequired="true">
    <values>
     <value prompt="Example: Nathen Benderson Park" uniquevalsfromfield="ParkName">ParkName = '[value]'</value>
    </values>
   </expression>
  </expressions>
   <graphicalsearchlabel>Use one of the graphical search tools to select Parks</graphicalsearchlabel>
   <spatialsearchlayer>false</spatialsearchlayer>
   <titlefield>ParkType</titlefield>
   <fields all="false">
    <field name="ParkType" alias="Park Type" gridfield="true" />
    <field name="ParkName" alias="Park Name" gridfield="true" />
    <field name="Address" alias="Address" gridfield="true" />
    <field name="Phone" alias="Phone Number" gridfield="true" />
    <field name="PublicAccess" alias="Public Access" gridfield="true"/>
   </fields>
   <!--<links></links>-->
   <zoomscale usegeometry="true" zoompercent="1.6" />
   <autoopendatagrid>true</autoopendatagrid>
   <relates>
    <relate id="2" label="Parks Information" enableexport="true" icon="assets/images/i_table.png">
     <fields all="false">
      <field name="ADA_Access" alias="Is ADA Accessible" />
      <field name="Concession" alias="Has Concesssions" />
      <field name="Restrooms" alias="Has Restrooms" />
      <field name="Showers" alias="Has Showers" />
      <field name="Playgrounds" alias="Has Playgrounds" />
      <field name="AthleticCourts" alias="Has Courts" />
      <field name="AthleticFields" alias="Has Ball Fields" />
      <filed name="CanoeKayakLaunch" alias="Has Kayak Launch" />
      <field name="BoatAccess" alias="Has Boat Access" />
      <field name="PicnicArea" alias="Has Picnic Areas" />
      <field name="CampingArea" alias="Has Camping" />
     </fields>
    </relate>
   </relates>
  </layer>
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
David,

   Are you using the source code version of the widget? I have found the issue causing the coded values to not appear when the layer has a sub type, but as version 3.2 is now two versions old I don't update older version of the widget.
0 Kudos
DavidColey
MVP Frequent Contributor
Hi Robert-
Thanks for the reply.  Yeah,  For us here in southwest Florida, hurricane season preparations tends to backlog my update frequency.  Yes I am using the source code version if I understand you correctly, although I typically download from the eSearch.zip Code Attachement download section, and not from github.  I'll be updating to 3.4 very shortly, and so wasn't going to spend alot of time on this, unless you had something already forked on github for this version, or had could direct me to a particular function in the mxml.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
David,

   The changes are not hard and are limited to two files the main eSearchWidget.mxml and the SearchWidgetFixedDG.mxml

So here are the code changes:

eSearchWidget.mxml > function createSearchResults > sub function inside of createSearchResults called displayFields:
Just replace this similar if block (main Changes in Red).
                            if(layerDetails && field){
                                var typeID:String = null;
                                if (layerDetails.typeIdField && fieldName.toUpperCase() == layerDetails.typeIdField.toUpperCase()){
                                    typeID = layerDetails.typeIdField ? graphic.attributes[fieldName] : null;
                                    // replace value with feature type name
                                    var featureType:FeatureType = getFeatureType(typeID);
                                    if (featureType && featureType.name){
                                        value = featureType.name;
                                    }
                                }else{
                                    // replace value with coded value name if one exists
                                    var codedValue:CodedValue = getCodedValue(fieldName, value, typeID);
                                    if (codedValue){
                                        value = codedValue.name;
                                    }
                                }
                            }


SearchWidgetFixedDG.mxml > function dProvider
Just replace this similar portion of the for block (main Changes in Red).
                        for each (fld in _layerDetails.fields){
                            var typeID:String = null;
                            if (_layerDetails.typeIdField && fld.name.toUpperCase() == _layerDetails.typeIdField.toUpperCase()){
                                typeID = _layerDetails.typeIdField ? attributes[fld.name] : null;
                                // replace value with feature type name
                                var featureType:FeatureType = getFeatureType(typeID,_layerDetails);
                                if (featureType && featureType.name){
                                    attributes[fld.name] = featureType.name;
                                }
                            }else{

SearchWidgetFixedDG.mxml > function rdProvider
Just replace this similar portion of the for block (main Changes in Red).
                        for each (fld in _rlayerDetails.fields){
                            var typeID:String = null;
                            if (fld.name == _rlayerDetails.typeIdField){
                                typeID = _rlayerDetails.typeIdField ? String(attributes[_rlayerDetails.typeIdField]) : null;
                                // replace value with feature type name
                                var featureType:FeatureType = getFeatureType(typeID,_rlayerDetails);
                                if (featureType && featureType.name){
                                    attributes[fld.name] = featureType.name;
                                }
                            }else{
0 Kudos
DavidColey
MVP Frequent Contributor
Thanks Robert, works like a charm.  Let's see, if I'm following the programming logic correctly, the original variable typeID string in the layerDetails if block is set to return the attributes of any given field and when employed on a subtype field or codedDomain field the reutrn will be descriptions as designed.  But when both subtypes and coded val domains descriptis are to be returned, the typeID has to essentially be cleared first, then set to return the decripts and not the codes... 

Anyway, hope I haven't embarrased myself to badly here, please feel free to correct me and it's always a pleasure working with you.  I'll shoot you a url when I put up a release build--

Thanks Again-
David
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
David,

   You are pretty well on track there. If the current field is the same as the field for the Sub Type then I need to get the value of that field and send it to the getCodedValues function as the typeID but if the field is not the same as the type id then the typeID should be null so that it actually gets the codedvalue from the field.
0 Kudos
DavidColey
MVP Frequent Contributor
Yes, yes, yes, well described . . . and thanks again.  I'll let you get back to your 3.4 changes 🙂
0 Kudos
JoshWhite
Honored Contributor
I'm sorry if this has been mentioned before, two many posts to check all of them.  I'm using Flex Viewer 3.2 and Version 3.2.3 of your Enchanced Search Widget.  I'm trying to use it to notify people in the 200 foot buffer of a parcel.  I've got everything set up to do the selection of parcels within this buffer area but I cannot seem to get the fixed datagrid to populate with anything.  The autohide and everything works and the datagrid window opens just no data is displayed there.  I attached my widget xml file.  If there is anything else that would help please let me know.
Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Josh,

  Just little attention to detail stuff... You have your fields defined but for some reason put them in the relate section and you did not specify any of them as gridfields.

        <layer>
            <token/>
            <definitionexpression/>
            <enableexport>true</enableexport>
            <name>Parcels</name>
            <url>your url here</url>
            <expressions>
                <expression alias="PIN" textsearchlabel="Search by Parcel ID Number (PIN):" isvaluerequired="true">
                    <values>
                        <value prompt="Example: 3072504001001000" isvaluerequired="true" autosubmit="false">PIN = '[value]'</value>
                    </values>
                </expression>
            </expressions>
            <graphicalsearchlabel>Use one of the graphical search tools to select a Parcel</graphicalsearchlabel>
            <spatialsearchlayer>true</spatialsearchlayer>
            <titlefield>OWNERNAME</titlefield>
            <fields all="false">
                <field name="PIN" alias="Parcel ID" gridfield="true"/>
                <field name="OWNERNAME" alias="Owner" gridfield="true"/>
                <field name="MAILADDR" alias="Mailing Address" gridfield="true"/>
                <field name="LEGALDESC" alias="Legal Description" gridfield="true"/>
                <field name="PropNum" gridfield="true"/>
                <field name="PropDir" gridfield="true"/>
                <field name="PropStrt" gridfield="true"/>
                <field name="COMMENTS" alias="Additional Info" gridfield="true"/>
            </fields>
            <links/>
            <zoomscale usegeometry="true" zoompercent="2"/>
            <autoopendatagrid>true</autoopendatagrid>
            <queryattachments>false</queryattachments>
            <relates />
            <symbology>
                <simplefillsymbol color="0xff0000" alpha="0.5">
                    <outline color="0xff0000" alpha="0.8" width="2"/>
                </simplefillsymbol>
            </symbology>
        </layer>
0 Kudos