Select to view content in your preferred language

Open Search Widget with "Search by Attribute" as default

2691
17
04-22-2011 08:16 AM
JustinRiggs
Emerging Contributor
Right now the Search Widget opens with "Select Features" as its default. Is there any way to change that so it opens with the "Search by Attribute" screen instead?
Tags (2)
0 Kudos
17 Replies
RobertScheitlin__GISP
MVP Emeritus
Justin,

It take one very simple code change... But you have to be using the source code not the pre-compiled viewer.

Add what is in red to the SearchWidget.mxml
<viewer:BaseWidget xmlns:esri="http://www.esri.com/2008/ags"
                   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:Search="widgets.Search.*"
                   xmlns:viewer="com.esri.viewer.*"
                   x="600" y="300"
     currentState="textInput"
                   widgetConfigLoaded="init(); wTemplate.selectedTitlebarButtonIndex = 1">
0 Kudos
JustinRiggs
Emerging Contributor
Hmmm, I must be using the precompiled version because the code changes didn't have any effect. Thanks anyway...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

  If you have the SearchWidget.mxml, than you have the source code and NOT the precompiled version. Did you clear your browsers cache?
0 Kudos
JustinRiggs
Emerging Contributor
Robert,

Yes, I cleared the cache. I also had the widget set to preload, but I turned that off and still no luck. I've copied and pasted the code sample you provided directly into the SearchWidget.mxml page, so I don't think I have any typos...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

   In flash Builder look at your problems window and see if there is anything listed there.
0 Kudos
JustinRiggs
Emerging Contributor
Robert,

It's not reporting any problems, but I do have something interesting to report. I'm working on two projects right now - one on 2.2 and one on 2.3. When I added your code on the 2.2 project it worked; when I added it to the 2.3 project it doesn't. I don't know why that would be, but maybe that will help you...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

  I just tested the exact same change in 2.3 and it worked fine...
0 Kudos
JustinRiggs
Emerging Contributor
Justin,

  I just tested the exact same change in 2.3 and it worked fine...


Weird. I'll keep toying around with it, but obviously this works. Case closed. (Thanks for your help)

UPDATE: In my 2.3 project, I had to add SearchWidget.mxml to Flex Modules under Project--> Properties. I can be a real knucklehead sometimes.
0 Kudos
DerekHunter
Emerging Contributor
Robert,

The only searchwidget.mxml I can find is under the eSearch widget folder.  I am using the Search widget and would like to enable the changes you reference above to make the search by attribute appear by default, but can't find the .mxml file.

Derek
0 Kudos