About "esri/tasks/query"  's question

3482
5
Jump to solution
02-22-2015 03:57 AM
Highlighted
New Contributor III

my codes:

3.png

1.png

in chorom:

2.png

Now  I confused,  my god  ,what happend??

they are the same in  local/web api !

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

Zhongren,

  Is there a reason that you are not using a local variable for query and queryTask in your initData function? Why would you want it to be scoped to the whole widget source by using 'this.' ? Your overall issue is a scope problem. Inside the execute block the scope of 'this' is not the same as it was before.

initData: function () {

  var query = new Query();

  query.outFields = [this.config.queryFields];

  query.outSpatialReference = this.map.spatialReference;

  query.where = this.config.queryWhere;

  var queryTask = new QueryTask(this.config.queryTaskUrl);

  queryTask.execute(query,

      lang.hitch(this, function (featureSet) {

        console.log(featureSet);

      }),

      lang.hitch(this, function (error) {

        console.log(error);

      })

  );

  .....

},

View solution in original post

Reply
0 Kudos
5 Replies
Highlighted
New Contributor III

Robert Scheitlin, GISPDan Patterson

thank you very much!!

Reply
0 Kudos
Highlighted
Occasional Contributor III

Hi, not sure what's going on there but can it be because of a typo where you are creating the new QueryTask?

`this.config.qeuryTaskUrl` vs. `this.config.queryTaskUrl`, swap the 'eu'?

Reply
0 Kudos
Highlighted
New Contributor III

Not  this  reason, i check every words , but   thank you very much  !

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Zhongren,

  Is there a reason that you are not using a local variable for query and queryTask in your initData function? Why would you want it to be scoped to the whole widget source by using 'this.' ? Your overall issue is a scope problem. Inside the execute block the scope of 'this' is not the same as it was before.

initData: function () {

  var query = new Query();

  query.outFields = [this.config.queryFields];

  query.outSpatialReference = this.map.spatialReference;

  query.where = this.config.queryWhere;

  var queryTask = new QueryTask(this.config.queryTaskUrl);

  queryTask.execute(query,

      lang.hitch(this, function (featureSet) {

        console.log(featureSet);

      }),

      lang.hitch(this, function (error) {

        console.log(error);

      })

  );

  .....

},

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor III

Thank you very much!    good  night!

Reply
0 Kudos