Select to view content in your preferred language

Query Widget

1294
7
02-05-2012 11:35 AM
WinstonZeng
Emerging Contributor
There is an issue in the Query Widget (http://help.arcgis.com/en/webapps/flexviewer/live/index.html?config=apps/config-query.xml) of the ArcGIS Viewer for Flex. I hope ESRI would like to change it in the future version. Currently the Query widget opens a list of all records and user must click again on a binocular search icon to get to the place where they can enter text. It should bypass that second click and go directly to the text entry window.

How can I modify the source code for Viewer? I believe that I should modify the file, QueryWidget.mxml and/or QueryResultItemRenderer.mxml.
Tags (2)
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus
Winston,

   What you are describing as an issue is actually the desired design behavior, it is the query Widget not the search widget. The query widget is used to display results for layers with predefined queries. It is unlikely that the designed behavior will be changed.

As far as what needs to be changed in the QueryWidget.mxml it is just this one line.

<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:Query="widgets.Query.*"
                   xmlns:viewer="com.esri.viewer.*"
                   widgetConfigLoaded="init()"
                   currentState="filterInput">


Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Winston,<br><br>   What you are describing as an issue is actually the desired design behaviour, it is the query Widget not the search widget. The query widget is used to display results for layers with predefined queries. It is unlikely that the designed behavior will be changed.<br><br>As far as what needs to be changed in the QueryWidget.mxml it is just this one line.<br><br>
&lt;viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"<br>                   xmlns:s="library://ns.adobe.com/flex/spark"<br>                   xmlns:mx="library://ns.adobe.com/flex/mx"<br>                   xmlns:Query="widgets.Query.*"<br>                   xmlns:viewer="com.esri.viewer.*"<br>                   widgetConfigLoaded="init()"<br>                  <strong><span style="color:#ff0000;"> currentState="filterInput"&gt;</span></strong>
<br><br>Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:<br><img src="http://gis.calhouncounty.org/FlexViewer2.5/Answer.jpg" alt="" border="0">
0 Kudos
WinstonZeng
Emerging Contributor
Hi Robert

Thanks a lot!

After I add the line of code, it did first open the text entry window. However, after 1 second it automatically changes back to the list of all records. I believe that I should change the code somewhere as well. Do you know how?

I use the query widget as a search keyword tool. It does search a keyword in all fields of a layer file. But many of my users complain that it should first open the text entry window instead of a list of all records.

Adding the line of code works on the search widget (http://help.arcgis.com/en/webapps/flexviewer/live/index.html?config=apps/config-search.xml), it opens the Search by Attribute window instead of the select features window. However, the search widget only searches a keyword in one field, not all fields of the layer. Can the Search widget use to search a keyword in all fields in a table or layer?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Winston,

   Sure here is the other line that needs to be changed to prevent the widget from changing to the results after a second:

Comment out this line of code in the init function:

                if (filterField)
                {
                    wTemplate.addTitlebarButton(ICON_URL + "i_searchtext.png", textFilterLabel, toggleFilterPanel);
                    wTemplate.addTitlebarButton(ICON_URL + "i_clear.png", textFilterClear, doClear);
                    wTemplate.selectedTitlebarButtonIndex = 1;
                    //this.currentState = "resultsList";
                }


To be able to search more than one field at a time would require you to built a custom widget using the FindTask instead of the QueryTask.

Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
WinstonZeng
Emerging Contributor
Hi Robert,

Now it works great! Thanks a lot.

BTW: It seems that the query widget can search a key word in multiple fields of a layer file. It works fine when I add multiple fields in the <fields> and <filterfield> section of the xml file such as QueryWidget_PoliceStations.xml.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Winston,

   The Query Widget does give you the appearance that it allows searching multiple fields but really you are filtering an Array collection and not really querying all the fields. What I mean by this is if you have 10,000 records in your data and your map service is configured to return 1,000 records max (which is the ArcGIS Server 10 default) then when you filter those results using the query widget you are doing just that filtering those thousand results and not actually querying the 10,000 possible results for that keyword.

Lets Try this one more time:

Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
DianeKouadio_N_Zi
Deactivated User
Hi Robert!!!!

i ve tried to duplicate que QueryWidget and rename it as CustomQuery because i would like to have a datagrid and a chart based on
the results of the query and having the possibility to bind the datagrid row to the map BUT I DONT MOOVE

i have add the mxml files in the properties->flex  modules of my project...
I HAVENT CHANGED THE FLEX VIEW CODE AND HAVE THE ERROR  sorry in french

"
Cette unité de compilation ne disposait pas d'entrée factoryClass indiquée dans les métadonnées Frame en vue de charger les bibliothèques d'exécution partagées configurées. Pour compiler sans bibliothèque d'exécution partagée, définissez l'option -static-link-runtime-shared-libraries sur vraie ou désactivez l'option -runtime-shared-libraries. QueryResultItemRenderer.mxml
/Project/src/widgets/CustomQuery "

if i duplicate the querywidget...what  change  do i have to do?

And for having the datagrid and the chart....do you have a code for me????
0 Kudos