Select to view content in your preferred language

FeatureLayer with Definition Expression and query features

3069
2
03-28-2012 09:53 AM
demdeberanz
Emerging Contributor
I set a definition expression in a feature layer and it rightly shows just the features that match this expression.
When I perform a query with queryFeatures function (or also with a query task) it gives me all the layer's features that match the query's where clause and not only the features that match both the definition expression and the query's where clause.

What am I doing wrong?

Thank you very much.
0 Kudos
2 Replies
ChadWilcomb
Deactivated User
Songissimo, try using the selectFeatures function against your Feature Layer that you had previously applied setDefinitionExpression.

var select = featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);

select.then(function (features) {
    console.log("select features result: ", features);
}



This is what I am using in my application do what you describe you are looking for.
0 Kudos
demdeberanz
Emerging Contributor
Songissimo, try using the selectFeatures function against your Feature Layer that you had previously applied setDefinitionExpression.

Code:
var select = featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);

select.then(function (features) {
    console.log("select features result: ", features);
}

This is what I am using in my application do what you describe you are looking for.


cwilcomb I'm glad to you  for both reply to my two posts. I've tested your solution but It doesn't behaves as I expected.
It enquiries the layer but anyway it gives me all feature in the layer that match the specific clause (the one defined by query element) instead of give only ones that match the specific condition that belong to the set selected with selectFeatures

This is very very strange, can it be a bug in the apis?
0 Kudos