no callback from selectFeatures

745
2
05-30-2013 10:45 AM
StevenHaslemore
Occasional Contributor
I'm running a selectFeatures against a table feature layer and there is no callback being generated.
I can see the results returned in the network traffic, and I've created a stripped down application that works, so it's not a service issue.

I'm stumped as to what is happening to my callback so any thoughts will be much appreciated, or anything wrong in the following code (it's within a backbone framework).

I think it's worth noting that a queryFeatures works just fine, so it doesn't seem like something is fundamentally breaking the callbacks. So a backup would be somehow getting the query features result into an attribute inspector related to the layer such that the results could be edited.

Thanks,
Steven

        initialize: function () {
          var _this = this;
          this.featureLayer = new esri.layers.FeatureLayer(this.layerConfig.url, {
            mode: this.layerConfig.mode, //MODE_ONDEMAND
            id: this.id,
            isEditable: 'true',
            outFields: ["*"]
          });

          dojo.connect(this.featureLayer, 'onLoad', function () {
            console.log('featureLayer onLoad called');
            _this.initEditing();
          });
        }


      initEditing: function(){
        var definition = "LIGHT_ID" + " = 'RSL-000002'"
        var query = new esri.tasks.Query();
        query.where = definition;

        var layer  = this.map._layers[this.id];

        layer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW,
          function (success) {
            console.log('select success');
          }, function (error) {
            console.log('select error');
        });
      }
0 Kudos
2 Replies
TracySchloss
Frequent Contributor
Did you ever get any resolution on this?  I'm seeing something very similar.  The first time I do the selectFeatures, the callback function is called.  For all subsequent selections, it never gets to the callback function.

I will try queryFeatures instead, but I'm real unclear about what the difference is between selectFeatures vs. queryFeatures.
0 Kudos
StevenHaslemore
Occasional Contributor
For me it turned out that I was defining the featurelayer mode incorrectly when reading it in from a config file. (attempting to set it with a string of 'esri.layers.FeatureLayer.MODE_SELECTION')

No error was thrown on the initialization but callbacks didn't come through at all. Not sure what could be causing subsequent failure.

Also, I think the main difference on the select vs query, selects appear on the featurelayer, so they appear in connected inspector tools and editing, query returns a discrete copy of the response.

Hope this helps.
0 Kudos