Select to view content in your preferred language

Enhanced-Search-Widget-for-FlexViewer Part II

136637
552
04-19-2012 08:03 AM
RobertScheitlin__GISP
MVP Emeritus
All,

   I am pleased to announce the next release of my eSearch Widget.

http://www.arcgis.com/home/item.html?id=5d4995ccdb99429185dfd8d8fb2a513e

Version 2.5.1.7 - 4/19/2012
* Added ability to search (flat/standalone/no geometry) tables.
* This time all Zooming uses the same scaling (popup, datagrid, widget results, zoom to all).
* Added Relates icon/button to datagrids so that you can click on it in the datagrid to
  open relates choice dialog.
* Move all skins to a skins package for cleaner organization.
* Links that are not associated with a field now work.
* Ability to disable the relates tab in the fixed widget is now configurable.
552 Replies
RhettZufelt
MVP Notable Contributor
do you mean something like the search centerline example from the example site (though it actually has three value statements)  http://gis.calhouncounty.org/FlexViewer3.0/index.html?config=config-eSearch.xml&search=2&slayer=3&ex... ?

If so, here is the snippet from the eSearchWidget.xml Robert has supplied with the widget that does that.

   <definitionexpression></definitionexpression>
   <enableexport>true</enableexport>
   <name>Road Centerlines</name>
   <url>http://gislap134/ArcGIS/rest/services/Highway/MapServer/5</url>
   <expressions>
    <expression alias="Road Name and Zip" textsearchlabel="Search by Road Name and Left Zipcode and Right Zip:">
     <values>
      <value prompt="Exmaple: ANDREW">RD_NAME = '[value]'</value>
      <value prompt="Exmaple: 36201"> AND ZIP_L = [value]</value>
      <value prompt="Exmaple: 36201"> AND ZIP_R = [value]</value>
     </values>
    </expression>
   </expressions>
   (I deleted the other expressions that didn't seem to apply)
(Don't forget the space before the AND as it is not in the example.xml this way)  Can also use OR instead if that is what you need.




Is this what you are after?


Below is a snippet that I am using.  It puts two options on the search widget, one lets you put in partial and does a LIKE operation, the other only finds exact matches.  But, they are both searching the same layer, same field. 
    <expression alias="SiteCode" textsearchlabel="Search by SiteCode: (enter search text in one box only)">
     <values>
      <value  prompt="Search for Matches:  Example: 100-D-" field="SITECODE">UPPER(SITECODE) LIKE UPPER('%[value]%')</value>
     </values>
     <values>
      <value  prompt="Search EXACT SiteCode" field="SITECODE">UPPER(SITECODE) = UPPER('[value]')</value>
     </values>
    </expression>



    <expression alias="SiteCode" textsearchlabel="Search by SiteCode: (enter search text in one box only)">
     <values>
      <value  prompt="Search for Matches:  Example: 100-D-" field="SITECODE">UPPER(SITECODE) LIKE UPPER('%[value]%')</value>
     </values>
     <values>
      <value  prompt="Search EXACT SiteCode" field="SITECODE"> OR UPPER(SITECODE) = UPPER('[value]')</value>
     </values>
    </expression>


In the first example, multiple fields are searched, in the second example, you choose which input to use and it searches the same fields but with different expression.  The third is similar to the second but will take inputs from both text box's, and if either match, you get the results.  Just remember, if you use an AND or OR statement, the first text box MUST have a value in it.


If I understand you correctly, below is what you need.

<expression alias="Tract" textsearchlabel="Search by Tract Number:
 <values>
  <value  prompt="Select All Records"   userlist="Select All Records" field="PRJTRACTNO">1=1</value>
 </values>
 <values>
  <value  prompt="Search Tract Number" field="PRJTRACTNO">UPPER(PRJTRACTNO) LIKE UPPER(%'[value]'%)</value>
 </values>
</expression>

R_
0 Kudos
JORGELAGOS2
Emerging Contributor
do you mean something like the search centerline example from the example site (though it actually has three value statements)  http://gis.calhouncounty.org/FlexViewer3.0/index.html?config=config-eSearch.xml&search=2&slayer=3&ex... ?

If so, here is the snippet from the eSearchWidget.xml Robert has supplied with the widget that does that.

   <definitionexpression></definitionexpression>
   <enableexport>true</enableexport>
   <name>Road Centerlines</name>
   <url>http://gislap134/ArcGIS/rest/services/Highway/MapServer/5</url>
   <expressions>
    <expression alias="Road Name and Zip" textsearchlabel="Search by Road Name and Left Zipcode and Right Zip:">
     <values>
      <value prompt="Exmaple: ANDREW">RD_NAME = '[value]'</value>
      <value prompt="Exmaple: 36201"> AND ZIP_L = [value]</value>
      <value prompt="Exmaple: 36201"> AND ZIP_R = [value]</value>
     </values>
    </expression>
   </expressions>
   (I deleted the other expressions that didn't seem to apply)
(Don't forget the space before the AND as it is not in the example.xml this way)  Can also use OR instead if that is what you need.




Is this what you are after?


Below is a snippet that I am using.  It puts two options on the search widget, one lets you put in partial and does a LIKE operation, the other only finds exact matches.  But, they are both searching the same layer, same field. 
    <expression alias="SiteCode" textsearchlabel="Search by SiteCode: (enter search text in one box only)">
     <values>
      <value  prompt="Search for Matches:  Example: 100-D-" field="SITECODE">UPPER(SITECODE) LIKE UPPER('%[value]%')</value>
     </values>
     <values>
      <value  prompt="Search EXACT SiteCode" field="SITECODE">UPPER(SITECODE) = UPPER('[value]')</value>
     </values>
    </expression>



    <expression alias="SiteCode" textsearchlabel="Search by SiteCode: (enter search text in one box only)">
     <values>
      <value  prompt="Search for Matches:  Example: 100-D-" field="SITECODE">UPPER(SITECODE) LIKE UPPER('%[value]%')</value>
     </values>
     <values>
      <value  prompt="Search EXACT SiteCode" field="SITECODE"> OR UPPER(SITECODE) = UPPER('[value]')</value>
     </values>
    </expression>


In the first example, multiple fields are searched, in the second example, you choose which input to use and it searches the same fields but with different expression.  The third is similar to the second but will take inputs from both text box's, and if either match, you get the results.  Just remember, if you use an AND or OR statement, the first text box MUST have a value in it.


If I understand you correctly, below is what you need.

<expression alias="Tract" textsearchlabel="Search by Tract Number:
 <values>
  <value  prompt="Select All Records"   userlist="Select All Records" field="PRJTRACTNO">1=1</value>
 </values>
 <values>
  <value  prompt="Search Tract Number" field="PRJTRACTNO">UPPER(PRJTRACTNO) LIKE UPPER(%'[value]'%)</value>
 </values>
</expression>

R_


Thanks so much. I am trying to implement the search with the AND using two fields.
<expressions>
    <expression alias="Property Parcels" textsearchlabel="Search by PRJTRACTNO AND OWNER">
        <values>
<value prompt="Enter Project Number">UPPER(PRJTRACTNO) LIKE UPPER(%'[value]'%)</value>
<value prompt="Enter Owner"> AND UPPER(OWNER) LIKE UPPER(%'[value]'%)</value>
       </values>
   </expression>
</expressions>

However I got the error which is showinfg in the attached image

Thanks

Jorge
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jorge,

      Your expression needs some work:

            <expressions>
                <expression alias="Property Parcels" textsearchlabel="Search by PRJTRACTNO AND OWNER">
                    <values>
                        <value prompt="Enter Project Number">UPPER(PRJTRACTNO) LIKE UPPER('%[value]%')</value>
                        <value prompt="Enter Owner"> AND UPPER(OWNER) LIKE UPPER('%[value]%')</value>
                    </values>
                </expression>
            </expressions>


Also you need to consider if you really need both % symbol. Let me explain what that is doing if you don't already know. If you enter a value of drew then the query would find values like 'Andrew Jones Rd' and 'Drew Pennington Rd', where id you were to use UPPER('[value]%') then it would only find 'Drew Pennington Rd'.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
All,

   Version 3.0.8 is now available:

Version 3.0.8 - 9/4/2012
* Added attribute to not display links that have null values.
* Fixed bug with sorting on joined data.
* Fixed bug with datefomat not being specified throwing error.
* Added a isvaluerequired attribute to expression values and expressions (see documentation for details).
* Added ability to define symbology at the layer level and widget level.
0 Kudos
RhettZufelt
MVP Notable Contributor
Thanks so much. I am trying to implement the search with the AND using two fields. 
<expressions> 
<expression alias="Property Parcels" textsearchlabel="Search by PRJTRACTNO AND OWNER"> 
<values> 
<value prompt="Enter Project Number">UPPER(PRJTRACTNO) LIKE UPPER(%'[value]'%)</value> 
<value prompt="Enter Owner"> AND UPPER(OWNER) LIKE UPPER(%'[value]'%)</value> 
</values> 
</expression> 
</expressions> 

However I got the error which is showinfg in the attached image 

Thanks 

Jorge


I would guess that your PRJTRACTNO is actualy a number field and not a text field. If so:

<expressions>
    <expression alias="Property Parcels" textsearchlabel="Search by PRJTRACTNO AND OWNER">
        <values>
 <value prompt="Enter Project Number">PRJTRACTNO = [value]<value>
 <value prompt="Enter Owner"> AND UPPER(OWNER) LIKE UPPER(%'[value]'%)</value>
       </values>
   </expression>
</expressions>



If I try to search a numeric field using text input, I get the same error that you posted.

R_

Of course, as Robert pointed out, the double wildcards can/will match a LOT of values.
0 Kudos
JORGELAGOS2
Emerging Contributor
I would guess that your PRJTRACTNO is actualy a number field and not a text field. If so: 

<expressions>
    <expression alias="Property Parcels" textsearchlabel="Search by PRJTRACTNO AND OWNER">
        <values>
 <value prompt="Enter Project Number">PRJTRACTNO = [value]<value>
 <value prompt="Enter Owner"> AND UPPER(OWNER) LIKE UPPER(%'[value]'%)</value>
       </values>
   </expression>
</expressions>



If I try to search a numeric field using text input, I get the same error that you posted. 

R_ 

Of course, as Robert pointed out, the double wildcards can/will match a LOT of values.


Thanks so much for trying to help me with this issue. Unfortunately, I got the same error and none of my fields are numeric (see my search boxes in the attached file)). Any more ideas?

This is how my code look now.

<expressions>
<expression alias="Property Parcels" textsearchlabel="Search by PRJTRACTNO AND OWNER">
<values>
<value prompt="Enter Project Number">PRJTRACTNO = [value]</value>
<value prompt="Enter Owner"> AND UPPER(OWNER) LIKE UPPER(%'[value]'%)</value>
</values>
</expression>
</expressions>

Thanks

jorge
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jorge,

    As this widgets developer I would suggest that you pay close attention to my responses to your inquiry. In my last post I corrected some of the text in your expression. Go back to my last post and copy the expression as your had the order of the single qoutes and the percent symbol backwards.
0 Kudos
AndrewThorup
Occasional Contributor
Robert,

Great job on this fantastic widget.

I am having an issue with the link functionality on one of my viewers.  There is supposed to be a url string with the parcel number (YPNO field) attached at the end to comlete the link.  Here is the code I have used in the eSearch.xml file:

                      
                        <links>
    <link includeinresults="true" alias="Lyon Co Assessor Parcel Search">
     <![CDATA[http://www1.lyon-county.org:403/cgi-bin/asw101?Parcel={YPNO}]]>
     <icon><![CDATA[assets/images/i_table.png]]></icon>
    </link>
   </links>


When the link is clicked in the viewer, the url appears in the address bar without the attached YPNO number.  I know I am supposed to wrap the field name in curly braces, and this same method works on all of the other viewers I have created for other counties.  I have had this problem for this viewer using versions 3.0.6, 3.0.7, and 3.0.8.  I have confirmed that YPNO is indeed the correct name for the field by checking at the rest endpoint.  I have also tried making the link work as a text field as well as a number field.  So far I have had no success.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jay,

   I would start with some simple trouble shooting. Test by removing the link prefix and just have the field itself in the link and see if once clicked it provides the fields value. Is the field YPNO one of the field in your fields tag? I notice that you have the includeinresults as true do you see the value of the YPNO field in the results?

                        <links>
                <link includeinresults="true" alias="Lyon Co Assessor Parcel Search">
                    <=!=[=C=D=A=T=A=[{YPNO}]=]=>
                    <icon><=!=[=C=D=A=T=A=[assets/images/i_table.png]=]=></icon>
                </link>
            </links>
0 Kudos
RhettZufelt
MVP Notable Contributor
Jorge,

    As this widgets developer I would suggest that you pay close attention to my responses to your inquiry. In my last post I corrected some of the text in your expression. Go back to my last post and copy the expression as your had the order of the single qoutes and the percent symbol backwards.


Guess I should pay more attention to that also as if I put the percents outside the quotes, I get the fault code 400 error also...
0 Kudos