Select to view content in your preferred language

Search results to grid.

802
5
05-24-2012 08:22 AM
AmandaHutsel
Emerging Contributor
I'm trying to search a feature layer and have the results show on a map and also in a grid.  Both are working, the bug is that when you hit the "Find" button once the results show on the map and then you have to hit it a second time for the results to show in the grid.  Any ideas on solving this would be helpful.  Here is my search function code:

var featureset:FeatureSet;
  
private function doHSearch():void
{
var str:String="Street_Address like '%" + addressText.text+"%'";
   
if(statusText.selectedIndex != -1)
{
  str=str+ " and ConStatus = '" + String(statusText.selectedItem) + "'";
}
   
if (refText.text != "")
{
  str=str+" and ReferenceNo = "+ refText.text
}
   
if (apnText.text != "")
{
  str=str+ " and AssessorParcelNo = " + apnText.text
}
   
historic.definitionExpression=str;
   
featureset = new FeatureSet(ArrayCollection(historic.graphicProvider).toArray());
ResultsGrid.dataProvider = featureset.attributes; 
}
Tags (2)
0 Kudos
5 Replies
ThomasMcCracken
Deactivated User
Amanda,

That's strange functionality.  Are you sure it's just not taking a while for the data to load into the grid?  Sometimes it takes a while for large feature sets to show up into the datagrid.  I would try waiting a little while before hitting the button again.  Otherwise, that's weird.  A second button click should be the same command as the first...

Thomas McCracken
GIS Analyst
Georgia Power Company
0 Kudos
AmandaHutsel
Emerging Contributor
I've waited 5 minutes and nothing happens until I hit the find button again.
0 Kudos
KenBuja
MVP Esteemed Contributor
What's the code behind the Find button (and it helps if you put the code inside the Code tags)?
0 Kudos
AmandaHutsel
Emerging Contributor
The code for the find button is this:

<s:Button click="doHSearch()" label="FIND"/>

I'm not really sure what you mean by "it helps if you put the code inside the Code tags".
0 Kudos
IvanBespalov
Frequent Contributor
Amanda,
what is your debugger shows?
Debugging Flex 4 applications (Adobe)

historic is smthing like FeatureLayer? listen it's update events. When the layer has finished updating its content - get graphicProvider and "play" with features.
...
historic.addEventListener(LayerEvent.UPDATE_END, onHistoricUpdateEnd);
...
protected function onHistoricUpdateEnd(event:LayerEvent):void
{
    if (event.updateSuccess)
    { 
        trace("layer 'historic' update success");
        var historicGraphicProvider:ArrayCollection = historic.graphicProvider as ArrayCollection;
        if (historicGraphicProvider && historicGraphicProvider.length > 0)
        {
            trace(historicGraphicProvider.length + " features found");
            featureset = new FeatureSet(historicGraphicProvider.toArray());
            ...
        }
    }
    else
    {
        trace("layer 'historic' update not success");
    }
}
...

here is working sample - using defenitionExpression
here is working sample with sources - using query (all conditions you can put as where clause string "address like ...")
0 Kudos