Query task does not return a feature

505
3
Jump to solution
05-09-2013 09:55 AM
srujand
New Contributor II
Hi All,
I am having trouble with performing a query task on feature layer.Here is the workflow.
I have a menu item when clicked will perform query task returning all features in that layer and load into a Dojo combo box.
This spatial query is supposed to get all the features  but it is not loading a particular feature "ENG_XING = 340124F" .
When I perform exact query from map service REST end point ,I see this record.

"primaryMapUrl" is the REST end point URL which is ArcGISDynamic Layer. I am querying a feature layer under this.
The feature "ENG_XING = 340124F" is not returning from the query.
I cant figure out where I am going wrong .Please take a look at my code and help me resolve this.
Here is my existing code:

<div dojoType="dijit.MenuItem" iconClass="searchbycrossingIcon" class="menuItem"  onclick="loadDotXingNumber()">DOT XING#</div> function loadDotXingNumber(){   var layerId = getlayerIdByName("primary_dataset","Active Road Crossings");   var queryTask = new esri.tasks.QueryTask(primaryMapUrl + "/"+layerId);      var query = new esri.tasks.Query();      query.returnGeometry = false;      query.outFields = ["OBJECTID","ENG_XING"];        query.where = "1=1" ;      queryTask.execute(query,populateDotXingNumbers);  }  else{   dijit.byId('dotXingDialog').show();  } } function populateDotXingNumbers(results){  var dotxingnumbers = [];  for (var i=0; i<results.features.length; i++){     dotxingnumbers.push(results.features.attributes["ENG_XING"]);    if(results.features.attributes["ENG_XING"]=="340124F"){alert("Hurray!I find Xing");}  }  if (dotxingnumbers.length>0){   dotxingnumbers = removeDuplicateArrVal(dotxingnumbers);   dotxingnumbers.sort();   isDotdivLoaded=true;   var dotXingData = "";   for (var j=0; j<dotxingnumbers.length;j++){    dotXingData += "{name : \"" + dotxingnumbers + "\"}";    if (j!=dotxingnumbers.length-1){     dotXingData += ",";    }    }   showDotXingNumbers(dotXingData);  } } function showDotXingNumbers(dotXingData) {    var dotxingnumbers = eval("new dojo.data.ItemFileReadStore({data: {identifier : \"name\", items : ["            + dotXingData +  "]}})");       var myDijit = new dijit.form.ComboBox({         id: "dotxingnumbers",         name: "name",         store : dotxingnumbers,         searchAttr: "name",         value:'',         promptMessage: dotXingEmptyText        });       dojo.byId("dotXing").appendChild(myDijit.domNode);       dijit.byId('dotXingDialog').show(); }
0 Kudos
1 Solution

Accepted Solutions
srujand
New Contributor II
rather than querying for everything and then searching for 340124F, why not just query for the feature you want?

query.where = "ENG_XING='340124F'" ;


That is true.But I would like to all the features and load them into a Dojo Comobo box like a drop down list of ENG_XING's.
Actually I posted another therad this time since I knew the query is returning 37527 features .
Here is the link to the thread and it got the answer.
http://forums.arcgis.com/threads/84263-Is-there-any-limit-on-number-of-features-a-query-task-returns

Please share your comments.

Thanks.

View solution in original post

0 Kudos
3 Replies
JohnGravois
Frequent Contributor
rather than querying for everything and then searching for 340124F, why not just query for the feature you want?

query.where = "ENG_XING='340124F'" ;
0 Kudos
JohnGravois
Frequent Contributor
sorry, i misunderstood.  you need to query for everything to populate your combobox.  you say that when you execute a 1=1 query directly in the REST endpoint for the layer, the feature is present.  if you set a breakpoint in your code and inspect the results, it is missing?
0 Kudos
srujand
New Contributor II
rather than querying for everything and then searching for 340124F, why not just query for the feature you want?

query.where = "ENG_XING='340124F'" ;


That is true.But I would like to all the features and load them into a Dojo Comobo box like a drop down list of ENG_XING's.
Actually I posted another therad this time since I knew the query is returning 37527 features .
Here is the link to the thread and it got the answer.
http://forums.arcgis.com/threads/84263-Is-there-any-limit-on-number-of-features-a-query-task-returns

Please share your comments.

Thanks.
0 Kudos