Querytask and recordcount

751
2
Jump to solution
10-18-2016 04:18 AM
MargaRaiz
New Contributor III

Hi,

I have a widget for permorming a query and draw some elements in the map. When I execute my query with the querytask I also write in a label "X record founded".

(...)

queryTask.execute(query, dojo.hitch(this, "drawRecords"));

},

drawRecords: function (featureSet) {

(...)

this.shelter.hide();

dojo.byId("myLabel").innerHTML = "X record founded";

}

And this works fine when I have >1 records in the featureset, BUT when I have zero results, drawRecords function is not triggered, so the shelter never disappeared and the message tellin 0 record founded never appears.

I have try several things, but nothing is working.. I know that querytask has the methoth "executeForCount" but I am not sure how to use it and if i need to keep  the "normal" execute in order to execute the query or if with one is enough..

any help?

Thanks!

Marga

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Marga,

  Strange.. Even if the query results no results you should still get to the complete event handler.

You should add an on error handler to see what is going wrong.

queryTask.execute(query, dojo.hitch(this, drawRecords), dojo.hitch(this, function(err){console.log(err);});

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Marga,

  Strange.. Even if the query results no results you should still get to the complete event handler.

You should add an on error handler to see what is going wrong.

queryTask.execute(query, dojo.hitch(this, drawRecords), dojo.hitch(this, function(err){console.log(err);});
MargaRaiz
New Contributor III

You were rigth, it was an error not handled.

Thanks!

0 Kudos