Select to view content in your preferred language

Enhanced Search Widget for FlexViewer 2.1

158244
767
10-25-2010 02:13 PM
RobertScheitlin__GISP
MVP Emeritus
All Here is my next widget in the FlexViewer 2.1 series

Special thanks to Erwan Caradec for contributing to this code.

The Enhanced Search Widget extends the standard search widget with a floating data grid and a new spatial query w/buffering.

http://www.arcgis.com/home/item.html?id=5d4995ccdb99429185dfd8d8fb2a513e
Tags (2)
0 Kudos
767 Replies
LisaArnold
Deactivated User
Hello all,

I am getting the error below when I try to search on any number fields, searching on text fields works just fine. I am using version 2.2.3.

Error: RPS Fault faultString="Unable to complete operation." faultCode="400" faultDetail="Unable to complete query operation."

Here are my expression lines from SearchWidget.xml
             <expression alias="FieldYr" textsearchlabel="Search Field Year [ Example: 2003 ]:">FieldYr = '[value]'</expression>
             <expression alias="FieldStatus" textsearchlabel="Search Field Status [ Example: Active ]:">upper(FieldStatus) = upper('[value]')</expression>

Any ideas?

And a side note, thanks for the awesome widget Robert!

Lisa Arnold
University of New Mexico
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lisa,

   The solution is quite simple:
<expression alias="FieldYr" textsearchlabel="Search Field Year [ Example: 2003 ]:">FieldYr = '[value]'</expression>


The above SQL expression is for when FieldYr is a string. Here is what you need because its a number:
<expression alias="FieldYr" textsearchlabel="Search Field Year [ Example: 2003 ]:">FieldYr = [value]</expression>


Notice no single quotes (which are for string) around the [value]
0 Kudos
LisaArnold
Deactivated User
Yep, that worked. Something I should have know really. Thanks for reminding me.

Lisa Arnold
0 Kudos
LisaArnold
Deactivated User
One other thing Robert - I know you said somewhere that any SQL statement could be used in the search. I want to search a field with different years in it, for example: FieldYr >= 2003 AND FieldYr <= 2005

If I type that in the search box I get the RPC fault error. Since it already knows to search the field FieldYr, I tried: >= 2003 AND <= 2005  This also produces the error.

Can you please give an example of the proper syntax here?

Thank you,
Lisa Arnold
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lisa,

   You have to escape the greater than and less than symbols as these are kind of commands in xml language. So you have to type:

FieldYr &gt;= 2003 AND FieldYr &lt;= 2005


so that the xml parser does not interpret then as something else
0 Kudos
LisaArnold
Deactivated User
Got it, though in case anyone uses this post for reference I had to change the syntax slightly.

FieldYr &gt:= 2003 AND FieldYr &lt:= 2005


Notice a colon after both gt and lt instead of a semicolon after gt.

Thanks!
Lisa Arnold
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lisa,

   Strange that that worked for you. I did mistype but it is actually suppose to be the other way around. ampersand gt semicolon and ampersand lt semicolon. That is the XML escape code for > and <.
0 Kudos
LisaArnold
Deactivated User
Hmm... not sure. If I put semicolons in both places I get the RPC fault error. I'm going to have to tell my users how to write their queries, so I can give examples with colons, but if some users are familiar with the XML escape code it could be confusing. Let me know if you think of any reasons why it might be working like this for me.

Thanks again,
Lisa Arnold
0 Kudos
DavidAllen
Frequent Contributor
OK - rookie question ...
I've gotten everything working, but I want to order the results of the queries. So I added the Order By command to the end of my query like this:
       <expression alias="Last name" textsearchlabel="Search for last name [ Example: Fuller ]:">upper(Last_name) like upper('%[value]%') ORDER BY "First_name"</expression>
           
The query runs without errors, but the output isn't ordered by the first name. Any tips here?

David Allen
0 Kudos
DavidAllen
Frequent Contributor
Robert - here's another question. Can you explain what the field attribute setting gridfield and gridfieldonly do? I'm seeting gridfield to true and false on different fields, but they all still show up in both the search results display and the pop-up box. I've tried setting gridfieldonly to true, and then the field doesn't show up in either the search results or the pop-up box.

Am I using these correctly?

            <fields all="false">
             <field name="First_name" alias="First name" gridfield="false"/>
             <field name="Middle_nam" alias="Middle name" gridfield="true"/>
                <field name="Last_name" alias="Last name" gridfield="true"/>
                <field name="B_month" alias="Birth - Month" gridfield="true"/>
                <field name="B_day" alias="Birth - Day" gridfield="true"/>
                <field name="B_year" alias="Birth - Year" gridfield="true"/>
                <field name="D_month" alias="Death - Month" gridfield="false"/>
                <field name="D_day" alias="Death - Day" gridfield="false"/>
                <field name="D_year" alias="Death - Year" gridfield="false"/>
                <field name="Comment" alias="Comment" gridfield="false"/>
                <field name="Comment_2" alias="Comment" gridfield="false"/>
                <field name="age" alias="Age at time of death" gridfieldonly="true"/>
            </fields>
0 Kudos