POST
|
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? Thank you very much. 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>
... View more
09-16-2015
03:25 AM
|
0
|
1
|
2232
|
POST
|
I am trying to get unique values from an only field from a service and after displaying field values in a listbox. Here (http://forums.esri.com/Thread.asp?c=158&f=2396&t=277241#top )there is an example that shows several fields in a first listbox, and after shows the fields values in a second listboxs How could i do the same but with an only FIELD instead of an array of field. I only need to display the values of an only field in a listbox. Anyone could help??? Any idea about how to subsitute ana array of fields per an single field in this code html?? Thank you very much. I am not developer and this is quite difficult for me <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>requestfieldvalues</title> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.3"></script> <script type="text/javascript" charset="utf-8"> dojo.require("esri.utils"); dojo.require("esri.tasks.query"); var queryTask, query; function init() { queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/2"); query = new esri.tasks.Query(); query.where = "1=1"; getFieldList(); } dojo.addOnLoad(init); function getFieldList() { esri.request({ url: "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0", content: { f:"json" }, handleAs: "json", callbackParamName: "callback", load: function(response, io) { var fields = response.fields; var options = []; dojo.forEach(fields, function(field) { options.push("<option value=\"" + field.name + "\">" + field.alias + "</option>"); }); dojo.byId("fields").innerHTML = options.join(""); }, error: function(error) { alert(error.message); } }); } function getFieldValues(field) { query.outFields = [field]; queryTask.execute(query, dojo.partial(displayValues, field)); } function displayValues(field, featureSet) { var options = [], values = [], value; dojo.forEach(featureSet.features, function(feature) { value = feature.attributes[field]; //add all values // options.push("<option value=\"" + value + ">" + value + "</option>"); //filter values to only display unique values if (dojo.indexOf(values, value) == -1) { values.push(value); options.push("<option value=\"" + value + "\">" + value + "</option>"); } }); dojo.byId("values").innerHTML = options.join(""); } </script> </head> <body> <select id="fields" onchange="getFieldValues(this.value);"></select> <select id="values" onchange="getFieldValues(this.value);"></select> </body> </html>
... View more
06-17-2015
03:24 AM
|
0
|
2
|
4142
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|