Solved! Go to Solution.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title>Get ArcGIS Server Map Service Layer Field Names</title> <script type="text/javascript"> var dojoConfig = { isDebug: true }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script> <style type="text/css"> #content { width: 800px; height: 200px; padding: 5px; overflow: auto; border: solid 2px #AAAAAA; background-color: #FFFFFF; font-family: monospace; -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0 0 0.5em black; -webkit-box-shadow: 0 0 0.5em black; -o-box-shadow: 0 0 0.5em black; box-shadow: 0 0 0.5em black; } .failure { color: red; } #status { font-size: 12px; } </style> <script type="text/javascript"> dojo.ready(function () { dojo.byId("url").value = "http://gisdemo1.cdm.com/ArcGIS/rest/services/MALDEN_MA_MOBILE_RELATE_FS/FeatureServer/1"; dojo.byId("content").value = ""; dojo.connect(dojo.byId("go"), "onclick", getContent); }); function getContent() { var url; dojo.byId("content").value = ""; dojo.removeClass(dojo.byId("content"), "failure"); dojo.byId("status").innerHTML = "Downloading..."; url = dojo.byId("url").value; if (url.length == 0) { alert("Please enter a URL."); return; } var requestHandle = esri.request({ "url": url, "content": { "f": "json" }, "callbackParamName": "callback", }); requestHandle.then(requestSucceeded, requestFailed); } function requestSucceeded(response, io) { var fieldInfo, pad; pad = dojo.string.pad; console.log("Succeeded: ", response); var fieldsWithDomains = {}; // loop throught the fields dojo.forEach(response.fields, function(field) { if ( field.domain ) { // use the field name as a key fieldsWithDomains[field.name] = field.domain; } }); var info = ""; // print out domain info for ( field in fieldsWithDomains ) { if ( fieldsWithDomains[field].codedValues ) { info += field + " has a CV domain, codes/values: \n"; dojo.forEach(fieldsWithDomains[field].codedValues, function(cv) { info += "\t" + pad(cv.code + ": ", 4, " ", true) + " " + cv.name + "\n"; }); } } console.log("info: ", info); dojo.byId("content").value = info; } function requestFailed(error, io) { console.log("Failed: ", error); dojo.addClass(dojo.byId("content"), "failure"); dojo.toJsonIndentStr = " "; dojo.byId("content").value = dojo.toJson(error, true); } </script> </head> <body style="font-family: Arial Unicode MS,Arial,sans-serif;"> <p>Use esri.request to download info coded value domains.</p> <p>Enter the URL for a layer with fields that have coded values domains:<br> <input type="text" id="url" size="75" /> <input id="go" type="button" value="GO" /> <br />Check the console for the full response. <span id="status"></span> </p> <p> <p>Fields with coded value domains:</p> <textarea id="content"></textarea> </p> </body> </html>
orgQuery = new esri.tasks.Query(); orgTask = new esri.tasks.QueryTask("http://" + mapDomain + "/ArcGIS/rest/services/serverNameAndLayer"); orgQuery.outFields = ["Name", "Program_type", "Enrollment"]; orgQuery.returnGeometry = false;
var locList = list.features; var locContent; locContent += "<table border='1'><tr><th>Name</th><th>Type</th><th>Enrollment</th></tr>"; for (var i = 0, l = locList.length; i < l; i++) { locContent += "<tr><td>" + list.features.attributes['Name'] + "</td>"; locContent += "<td>" + list.features.attributes['Program_type'] + "</td>"; locContent += "<td>" + list.features.attributes['Enrollment'] + "</td>"; } locContent += "</tr></table>"; dojo.byId("schoolNameResults").innerHTML = locContent;
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title>Get ArcGIS Server Map Service Layer Field Names</title> <script type="text/javascript"> var dojoConfig = { isDebug: true }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script> <style type="text/css"> #content { width: 800px; height: 200px; padding: 5px; overflow: auto; border: solid 2px #AAAAAA; background-color: #FFFFFF; font-family: monospace; -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0 0 0.5em black; -webkit-box-shadow: 0 0 0.5em black; -o-box-shadow: 0 0 0.5em black; box-shadow: 0 0 0.5em black; } .failure { color: red; } #status { font-size: 12px; } </style> <script type="text/javascript"> dojo.ready(function () { dojo.byId("url").value = "http://gisdemo1.cdm.com/ArcGIS/rest/services/MALDEN_MA_MOBILE_RELATE_FS/FeatureServer/1"; dojo.byId("content").value = ""; dojo.connect(dojo.byId("go"), "onclick", getContent); }); function getContent() { var url; dojo.byId("content").value = ""; dojo.removeClass(dojo.byId("content"), "failure"); dojo.byId("status").innerHTML = "Downloading..."; url = dojo.byId("url").value; if (url.length == 0) { alert("Please enter a URL."); return; } var requestHandle = esri.request({ "url": url, "content": { "f": "json" }, "callbackParamName": "callback", }); requestHandle.then(requestSucceeded, requestFailed); } function requestSucceeded(response, io) { var fieldInfo, pad; pad = dojo.string.pad; console.log("Succeeded: ", response); var fieldsWithDomains = {}; // loop throught the fields dojo.forEach(response.fields, function(field) { if ( field.domain ) { // use the field name as a key fieldsWithDomains[field.name] = field.domain; } }); var info = ""; // print out domain info for ( field in fieldsWithDomains ) { if ( fieldsWithDomains[field].codedValues ) { info += field + " has a CV domain, codes/values: \n"; dojo.forEach(fieldsWithDomains[field].codedValues, function(cv) { info += "\t" + pad(cv.code + ": ", 4, " ", true) + " " + cv.name + "\n"; }); } } console.log("info: ", info); dojo.byId("content").value = info; } function requestFailed(error, io) { console.log("Failed: ", error); dojo.addClass(dojo.byId("content"), "failure"); dojo.toJsonIndentStr = " "; dojo.byId("content").value = dojo.toJson(error, true); } </script> </head> <body style="font-family: Arial Unicode MS,Arial,sans-serif;"> <p>Use esri.request to download info coded value domains.</p> <p>Enter the URL for a layer with fields that have coded values domains:<br> <input type="text" id="url" size="75" /> <input id="go" type="button" value="GO" /> <br />Check the console for the full response. <span id="status"></span> </p> <p> <p>Fields with coded value domains:</p> <textarea id="content"></textarea> </p> </body> </html>
great, thank you!
...any idea why I get 'undefined' as a result for the same field attribute in my infoWindow?
The infoWindow text layout structure is the same as the layout given above..I built the tabbed infoWindow around this example:
http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm#jssa...