Select to view content in your preferred language

Record Count of a Feature Layer

3340
11
Jump to solution
12-20-2013 06:20 AM
ionarawilson1
Deactivated User
I am filtering a non-spatial feature service cast a feature layer. How can I get the record count after the search is complete? I know I can use  the length of feature layer graphic provider if the feature layer is an actual feature layer. But how can I the number of records for a non-spatial table (named yourTable)? How can I modify the last line of the code snippet in this case?
Thank you so much in advance
Thanks

private function doSearch():void    {          myAttributeTable.featureLayer = myFeatureLayer         var defexpr:String =  searchattribute +  eqsymbol +  "'"  +  qText.text  + "'";      yourTable.definitionExpression = defexpr     myAttributeTable.featureLayer = yourTable     Alert.show(defexpr)     totalGraphicsShown = "Total records shown: " + (yourTable.graphicProvider as ArrayCollection).length 
Tags (2)
0 Kudos
11 Replies
ionarawilson1
Deactivated User
Hi Robert,

I tried that but I get "null RECORDS", when I run the search

   private function doSearch():void
   {
    
    
    myAttributeTable.featureLayer = myFeatureLayer
    
    var defexpr:String =  searchattribute +  eqsymbol +  "'"  +  qText.text  + "'";
//    var defexpr:String =  searchattribute +  eqsymbol +  "'"  +  qText.text  + zerotime + "'";
    yourTable.definitionExpression = defexpr
    myAttributeTable.featureLayer = yourTable
    Alert.show(defexpr)
     
    var query:Query = new Query();
    query.where = defexpr
    query.returnGeometry = false;
    
    yourTable.queryCount(query, new AsyncResponder(onResult, onFault));
    
    
    function onResult(count:Number, token:Object):void
    {
     var countstring:String
     countstring = count as String;
     numberofrecords.text = countstring + " RECORDS" ;
    
    }
    
    function onFault(info:Object, token:Object = null):void
    {
     
    }

}

And the mxml:

   <mx:Text width="65" id="numberofrecords"
      text="test"/>
0 Kudos
ionarawilson1
Deactivated User
This is what worked for  me:

var defexpr6:String =  "DateComplete >= " +   "'"  +  date1.text  + "'" + " AND DateComplete <= " + "'"  +  date2.text  + "'";      //    var defexpr:String =  searchattribute +  eqsymbol +  "'"  +  qText.text  + zerotime + "'";      yourTable.definitionExpression = defexpr6      myAttributeTable.featureLayer = yourTable      myAttributeTable.visible = true;      Alert.show(defexpr6)      query.where = defexpr6;      query.objectIds=[];      query.returnGeometry = false;      queryTask.executeForIds(query);     var objectIdsArray = [];    function  executeForIdsOnResult(event:QueryEvent):void         {          queryTask.removeEventListener(QueryEvent.EXECUTE_FOR_IDS_COMPLETE,executeForIdsOnResult);     objectIdsArray = event.objectIds;     numberofrecords.text = objectIdsArray.length.toString();         } 


And the mxml

 <esri:QueryTask id="queryTask"       url="http://tfsgis-iisd01:6080/arcgis/rest/services/SARS_WILSON/RELATED_TABLES/FeatureServer/1"       executeForIdsComplete="executeForIdsOnResult(event)"       useAMF="false"              />   <esri:Query id="query"      outFields=""       returnGeometry="false"      />           <mx:Text width="65" id="numberofrecords"         text="test"/>
0 Kudos