jmaxwell1562

filteringSelect not returning values

Discussion created by jmaxwell1562 on May 3, 2011
Latest reply on May 10, 2011 by hzhu
I need a little help with the filtering select.  It's not returning any values, and when I enter text into the selectbox I get a "the value entered is not valid".

Any help is appreciated.

Thanks--the code is below

____________________________________

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=7" />
  <title>FilterSelect Query</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript">djConfig = { parseOnLoad:true };</script>
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0"></script>


    <script type="text/javascript">
//Be sure to define you dojo components
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.data.ItemFileReadStore");

//Our main initialization function, called at just the right time
function init () {
  //Create your query
  //var queryTask = new esri.tasks.QueryTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer/0");
      // var queryTask = new esri.tasks.QueryTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer/0");
      var queryTask = new esri.tasks.QueryTask("http://dingo.gapanalysisprogram.com/ArcGIS/rest/services/PADUS/PADUS_status/MapServer/0");
        //set the onComplete event handler, in this case, when the query is complete, call initLineID,
  //production code would handle handle the error callback as well
  dojo.connect(queryTask, "onComplete", initLineID);
 
  //build and execute your query
  var query = new esri.tasks.Query();
        //query.outFields = ["field_name"];
        query.outFields = ["P_Des_Nm"];
  query.text = "all";
        query.returnGeometry = true;
  queryTask.execute(query);
}

function initLineID(features) {
    var lineIdObjects = [];
  dojo.forEach(features.features, function(feature) {
   lineIdObjects.push({"name": feature.attributes.P_Des_Nm});;
        });
 
  //Build the appropriate data object for our data component
  var data = {
     "identifier": "name",
     "items": lineIdObjects
  }
 
  //bind the data object to the datastore
  var lineDataStore = new dojo.data.ItemFileReadStore({data: data});

        //bind the data store to the FilteringSelect component
        dijit.byId("lineid").store = lineDataStore;
  }
 
  function doSomething(v) {
   alert(v);
  }
  
dojo.addOnLoad(init);
</script>

<body class="tundra">
<input dojoType="dijit.form.FilteringSelect"
        id="lineid"
        searchAttr="name"
           name="widgetName"
           onChange="doSomething(this.value)">
</body>
</html>

Outcomes