FeatureLayer selectFeatures issue on subsequent queries

696
2
11-29-2011 09:23 AM
ChristopherJennings
New Contributor II
I'm having an issue with the featureLayer.selectFeatures method in the API. I'm using v2.5 compact
On the first query attempt, everything works fine:
- Not using a "where" statement
- objectIds set to valid value
- feature is successfully returned.

However, on subsequent queries (using the exact same code) here are my results:
- A "where" statement is added even though I didn't specify one, with the OBJECTID value from the first feature that I queried. It's almost as if the previous query result's OBJECTID is being cached.
- Feature is not returned because the OBJECTID value is from the previous query, not from the new query.

My query object (esri.tasks.Query) is scoped locally to the method, so I know it's not a global variable issue. But, for some reason, a "where" statement is added automatically when the HTTP request is made (verified by inspecting the request in Fiddler). I've even manually set the query.where statement = null but this has no effect. The where statement is added anyway.

I've also manually created a where statement that includes the new OBJECTID value (instead of specifying in the query.ObjectIds param), but the HTTP request includes the value from the previous query anyway. Ex: "where OBJECTID = 1 and ID= 3 and OBJECTID=3. So, two OBJECTID values are added.

Here is my method's code:
function searchForStructure(feature_object_ids) {
    var feature_objectid_string = feature_object_ids.join(",");
    var query = new esri.tasks.Query();
    query.outSpatialReference = { "wkid": 102100 };
    query.returnGeometry = true;
    query.outFields = ["*"];
    query.where = null;
    query.objectIds = [feature_id_string];
    structuresLayer.clearSelection();
    structuresLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
}


Has anyone else noticed this behavior?
Thanks,
Chris
0 Kudos
2 Replies
SumitSharma
New Contributor III
Hey Chris,

IS  query.objectIds = [feature_id_string];

or

query.objectIds=[feature_objectid_string];


Sumit
0 Kudos
ChristopherJennings
New Contributor II
Sorry, that was a typo when I transferred the code to the post.
It should read:
query.objectIds=[feature_objectid_string];

My main concern is that a "where" clause is added with the previous search's OBJECTID even though I'm not specifying a "where" clause.
0 Kudos