2

I would like to populate a list on a select combobox using jquery with data from an arcserver service.I'm wondering if this is possible and if so how i would implement it. I'm using the esri javascript api v3.13 and arcserver. I did it before using DOJO but now i need Jquery instead of Dojo to implement my old code with Bootsrap web mobile aplication.

What i need is to click on the select option and the code should access to an unique field in my service layer and then it should show which value options i could choose(For example a field called Visietd which unic values are yes or no)

For example how should i write dijit.byid("fiedname") in jquery instead of Dojo?? For example how should i write dojo.addOnLoad(init) in jquery instead of Dojo?? Any idea?

CODE WITH DOJO INTENDED TO BE CHANGED TO JQUERY:

The code below makes a query in my service filtering the field "Visitado" :After this that data is stored with the unique field options values and it is populated the list (in a select in the html) with that options.

Do I need to change everything, or perhaps it is ok only changing dijit.byid (maybe with $("#Visitado")) and dojo.addOnLoad(init); ??

function init() {

      var queryTask7 = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/telefonica/brazil/MapServer/0");

    //Define query parameters
    var query7 = new esri.tasks.Query();
    query7.outFields = ["Visitado"];
    query7.returnGeometry = false;
    query7.where  = "Visitado  <> ''";
    queryTask7.execute(query7,populateList);


   }

 function populateList(results) {
    //Populate the dropdown list box with unique values
    var zone;
    var values = [];
    var testVals={};

    //Add option to display all zoning types to the dropdown list 
    //values.push({name:"ALL"})

    var features = results.features;
    dojo.forEach (features, function(feature) {
      zone = feature.attributes.Visitado;
      if (!testVals[zone]) {
        testVals[zone] = true;
        values.push({name:zone});
      }
    });

    var dataItems = {
           identifier: 'name',
           label: 'name',
           items: values
    };
    var store = new dojo.data.ItemFileReadStore({data:dataItems});
    dijit.byId("Visitado").set("store", store); 
  }


  dojo.addOnLoad(init);

 //OLD HTML CODE NEEDED FOR DOJO
  Visitados:  
 <select id="Visitado"        dojotype="dijit.form.ComboBox"                                          autoComplete="true" forceValidOption="true" value="Seleccione" ></select>

 //NEW HTML CODE NEEDED FOR JQUERY AND BOOTSRAP
  <select id="basic" class="selectpicker show-tick form-control">
  </select>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.