|
POST
|
I am running a querytask against a school layer and I need to be able to present the data in a dgrid with a rowrenderer. I'm getting stuck formatting the data to populate the dgrid. I'm new to the AMD format, I might not be using arrayUtil.map properly. I commented out most of this, just to verify that my queryTask is executing. It is, but restoring the entire function, it fails, just firing my errorHandler instead. The error comes back 'undefined', which is no help at all! I'm pretty sure the problem is in the lines that define the variable 'data'. function createSchoolList (results) { var resultsLength = results.featureSet.features.length; var data = []; var schoolFeatures = results.featureSet.features; if (dGridStacked) { dGridStacked.refresh(); } if (dGridTable) { dGridTable.refresh(); } data = arrayUtil.map(results, function(schoolFeatures){ return { 'facility': schoolFeatures.attributes[Facility], 'address': schoolFeatures.attributes[Address], 'city': schoolFeatures.attributes[City], }; }); dGridStacked = new dgrid.Grid({ renderRow: renderRowFunction, showHeader: true }, "searchResultsGrid"); dGridStacked.startup(); dGridStacked.renderArray(data); dGridStacked.sort('facility'); dGridStacked.on('.dgrid-row:click', function(event){ highlightGridSelection(event, dGridStacked); }); console.log(data); } function renderRowFunction (obj,options) { var template = '<div class="title">${0}</div><div class="details">Address: ${1}</div> <div class="details">City: ${2}</div>'; return dojo.create("div",{ innerHTML : dojo.string.substitute(template,[obj.facility,obj.address,obj.city]) }); }
... View more
09-26-2013
07:53 AM
|
0
|
7
|
2250
|
|
POST
|
That works great, thanks! You even got the sort I needed.
... View more
09-26-2013
05:09 AM
|
0
|
0
|
2920
|
|
POST
|
I have a layer of school districts that contains both the school district name and a district ID number. I have a layer of schools which contains just the district ID number. I'm populating my dijit.form.Select from the attributes of the school district layer. I need the list to appear as district names, but at the same time, it would be nice if the values were the district IDs. Then I could fire off a query on the school layer using a where clause without having to do any other hoop jumping (I think). This code works to populate my dropdown, I'd just like it to be a little more functional. function populateDropDownList(){ var queryTask = new QueryTask(educationLayer.url + "/3"); var query = new Query(); query.outFields = ["DIST_NAME"]; query.where = "1=1"; query.returnGeometry = false; queryTask.on('complete', resultsHandler); queryTask.on('error', errorHandler); queryTask.execute(query); } function resultsHandler(results){ select = registry.byId("distSelect");// a dijit.form.Select districtList.length = 0; var numResults = results.featureSet.features.length; for (var j = 0; j < numResults; j++) { var distName = results.featureSet.features .attributes.DIST_NAME; //note the attribute name for the district code is DIST_CODE districtList.push(distName); } districtList.sort(); var testList = arrayUtil.map(districtList, function (item, index){ return { label:item, value:item }; }); select.addOption(testList); }
... View more
09-25-2013
01:20 PM
|
0
|
21
|
11342
|
|
POST
|
I'm thinking that 'dirty = dirty' means the same thing as '1=1' Neither worked. I made a sample that isn't using any secure data, which has eliminated that as the culprit, it still doesn't work for me. As far as seeing whether or not the query is OK on the click, I think the errors I'm seeing in the console are telling me that 'no' the query isn't executing properly, either with "", " ", or some other expression that resolves as true, like 1=1.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<title>Feature Layer Filter Expression Example</title>
<link rel="stylesheet" type="text/css" href="https://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" type="text/css" href="https://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css" />
<link rel="stylesheet" type="text/css" href="https://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/dijit/css/Popup.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript">
var dojoConfig = {
parseOnLoad: true
};
</script>
<script type="text/javascript" src="https://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"></script>
<script type="text/javascript">
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.dijit.Popup");
dojo.require("esri.layers.FeatureLayer");
dojo.require("dijit.form.Select");
dojo.require("esri.IdentityManager");
var map;
var startExtent;
var buildingLayer;
var buildingInfoTemplate;
var infoTemplateContent;
var pathName = "https://ogitest.oa.mo.gov";
var buildingAgencyList = [];
function init(){
esri.config.defaults.io.proxyUrl = pathName + "/proxy/proxy.ashx";
var highlightFillSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 255, 0]), 3), new dojo.Color([255, 255, 0, 0.05]));
var highlightMarkerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 22, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 255, 0]), 2), new dojo.Color([255, 255, 0, 0.5]));
var popup = new esri.dijit.Popup({
fillSymbol: highlightFillSymbol,
lineSymbol: false,
markerSymbol: highlightMarkerSymbol
}, dojo.create("div"));
var spatialReference = new esri.SpatialReference({
wkid: 102100
});
startExtent = new esri.geometry.Extent(-10583000, 4287025, -9979000, 4980462, spatialReference);
map = new esri.Map("mapDiv", {
extent: startExtent,
fitExtent: true,
infoWindow: popup,
basemap: "gray"
});
map.infoWindow.resize(275, 600);
var countyLayer = new esri.layers.ArcGISDynamicMapServiceLayer(pathName + "/ArcGIS/rest/services/BaseMap/county_simple/MapServer", {
id: "countyLayer"
});
map.addLayer(countyLayer);
buildingInfoTemplateContent = "<b>${Facility}</b><br>" +
"Address: ${Address}<br>" +
"City: ${City}<br>" +
"Type: ${Type}<br>" +
"Years: ${Years}" ;
buildingInfoTemplate = new esri.InfoTemplate();
buildingInfoTemplate.setTitle("${Facility}");
buildingInfoTemplate.setContent(buildingInfoTemplateContent);
buildingLayer = new esri.layers.FeatureLayer(pathName + "/ArcGIS/rest/services/BaseMap/Education/MapServer/2", {
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
id: "buildingLayer",
outFields: ["*"],
infoTemplate: buildingInfoTemplate
});
var buildingSymbol = new esri.symbol.PictureMarkerSymbol('images/orangeDiamond.png', 24, 24);
var buildingRenderer = new esri.renderer.SimpleRenderer(buildingSymbol);
buildingLayer.setRenderer(buildingRenderer);
map.addLayer(buildingLayer);
populateBuildingDropDown(buildingLayer);
}
function pointToExtent(map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleraceInMapCoords = toleranceInPixel * pixelWidth;
return new esri.geometry.Extent( point.x - toleraceInMapCoords,
point.y - toleraceInMapCoords,
point.x + toleraceInMapCoords,
point.y + toleraceInMapCoords,
map.spatialReference );
}
function populateBuildingDropDown(buildingLayer){
buildingAgencyList.length = 0;
var queryTask = new esri.tasks.QueryTask(buildingLayer.url);
var query = new esri.tasks.Query();
query.outFields = ["*"];
query.where = "1=1";
query.returnGeometry = false;
//populates the pick list searching state facilities by agency
dojo.connect(queryTask, "onComplete", function (featureSet){
var select = dijit.byId("facilitySelect");
dojo.forEach(featureSet.features, function (feature){
var value= feature.attributes.Type;
buildingAgencyList.push(value);
});
buildingAgencyList.sort();
var sortedList = sortAndRemoveDuplicates(buildingAgencyList);
for (var i = 0; i < sortedList.length; i++) {
var bAgencyName = sortedList;
select.addOption({
label: bAgencyName,
value: bAgencyName
});
}
});
queryTask.execute(query);
}
function sortAndRemoveDuplicates(arr) {
var copy = arr.slice(0);
arr.length = 0;
for (var i = 0, len = copy.length; i < len; ++i) {
if (i === 0 || copy != copy[i - 1]) {
arr.push(copy);
}
}
return arr;
}
function filterFacilityByType() {
var e = dijit.byId("facilitySelect");
var code = e.value;
map.graphics.clear();
map.infoWindow.hide();
var filterExpression = "Type = '" + code + "'";
buildingLayer.setDefinitionExpression(filterExpression);
buildingLayer.setVisibility(true);
}
function toggleLayer (layerId) {
var layer = map.getLayer(layerId);
if (layer.visible){
layer.setVisibility(false);
map.infoWindow.hide();
}else{
layer.setVisibility(true);
}
}
function clearBuildingLayer () {
var exp = "";
var exp = "1=1";
var dirty = (new Date()).getTime();
buildingLayer.setDefinitionExpression(dirty + "=" + dirty);
//buildingLayer.setDefinitionExpression(exp);
buildingLayer.refresh();
var select = dijit.byId("facilitySelect");
select.reset();
map.graphics.clear();
map.infoWindow.hide();
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false"
style="width: 100%; height: 100%; margin: 0;">
<div id="mainHeader" dojotype="dijit.layout.ContentPane" region="top" >
Filter Expression Example
</div>
<div id="mapDiv" dojotype="dijit.layout.ContentPane" region="center" style="overflow:hidden;"splitter="true">
</div>
<div id="leftPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'left'"splitter="true" >
<button dojoType="dijit.form.Button" id="btnBuilding" class="togglebutton" iconClass="buildingIcon" onClick="toggleLayer('buildingLayer');" title="Turn State Facilities On/Off">
Facility
</button>
</br>
Filter facilities by type:
<select data-dojo-type="dijit.form.Select" id="facilitySelect" onchange="filterFacilityByType()" title="Display homes by level of care">
<option>Select type</option>
</select>
<button id="btnClear" dojotype="dijit.form.Button" onClick="clearBuildingLayer();" title="Clear Filter by Agency">Clear Results</button>
</div>
</div>
</body>
</html>
... View more
09-11-2013
09:05 AM
|
0
|
0
|
930
|
|
POST
|
I'm noticing different behavior depending on the browser. In Chrome and IE, if I hit the button a 2nd time, then all the features display. In Firefox, hitting the clear button a 2nd time makes no difference.
... View more
09-11-2013
06:25 AM
|
0
|
0
|
930
|
|
POST
|
I made a copy this AM and left only the relevant code to my situation. One thing I should mention is that I am using IdentityManager, since my service is secure. When I hit my Clear Results, in my Firebug console log, I'm getting messages, first a I see several that show that my Get request, I assume on my featurelayer, was aborted. These are followed for a corresponding number of CancelError: Request canceled. messages. I get these every time I attempt to set the filter expression to "". I can continue to use my dropdrown that sets the filter to a regular expression, it's only the filterexpression of "" that is generating these errors. Could there be some bug related to feature layers, filterexpressions, identitymanager, security etc.?
... View more
09-11-2013
05:51 AM
|
0
|
0
|
3266
|
|
POST
|
Unfortunately no, it's for an internal project with rather sensitive data. I'm also trying to redo the whole thing to be AMD style instead, but that's not going very well either! I'll see if I can put something together, but I'm sure as soon as I lift out a portion of the code to show as an example, it will all work!
... View more
09-10-2013
10:44 AM
|
0
|
0
|
3266
|
|
POST
|
I've tried both "" and " ". The space, or lack of one hasn't made any difference. If I look at the layer, it's defaultDefinitionExpression is defined as "". I originally had code that told it to set the definitionExpression back to this default.
buildingLayer.setDefinitionExpression(buildingLayer.defaultDefinitionExpression);
That seems logical to me, but that didn't work either. Putting breakpoints in my code, I can see that I am setting the definitionExpression to "". But that doesn't take me back to all features, I'm still seeing none.
... View more
09-10-2013
08:14 AM
|
0
|
0
|
3266
|
|
POST
|
I just realized how old the version of the JS API was that I'm using (3.2). I updated my references and it worked, just one time. When I reloaded the page, now it's back to removing all the features. Very wierd!
... View more
09-10-2013
06:52 AM
|
0
|
0
|
3266
|
|
POST
|
The fiddle doesn't work for me. It just stays on South Carolina, no matter which button I push. I changed my code to switch my filter expression to
buildingLayer.setDefinitionExpression(" ");
Instead of showing all features, it shows none at all.
... View more
09-10-2013
06:24 AM
|
0
|
0
|
3266
|
|
POST
|
I have a dropdown list of choices that I'm using as a parameter for a filterExpression on a featureLayer. This works just fine, until I tried to remove the filter. Looking through the API, I'm not seeing anything that seems suitable to get rid of this. I thought I could just set it back to the original default filterExpression (which returns as "" if I look at the layer before I set the filter). I've also tried using clearSelection, which doesn't seem like what I want, since I didn't do a selection of features, I set a filter. function filterFacilityByAgency() {
var e = dijit.byId("facilitySelect");
var code = e.value;
map.graphics.clear();
map.infoWindow.hide();
var filterExpression = "Agency = '" + code + "'";
buildingLayer.setDefinitionExpression(filterExpression);
buildingLayer.setVisibility(true);
}
function clearBuildingLayer () {
var orgExp = map.getLayer('buildingLayer').defaultDefinitionExpression; //NOTE: returns ""
buildingLayer.setDefinitionExpression(orgExp);
map.getLayer('buildingLayer').clearSelection;
var select = dijit.byId("facilitySelect");
select.reset();
}
... View more
09-09-2013
10:41 AM
|
0
|
13
|
8130
|
|
POST
|
So far it sounds like no one has ever heard of such a thing happening. From the matrix I've seen, 9.3 geodatabases are supported by 11g Oracle. I'm not in a position to upgrade my geodatabase to 10 at this time, not because of the geodatabases, but because of my ArcGIS Server version. We don't have the resources to build the servers to support 10.1. I'm having the data restored from backups today. If none of this works, I'm going to punt Oracle and just go to file geodatabases. This whole exercise is proving to be way more trouble than it's worth.
... View more
09-03-2013
05:25 AM
|
0
|
0
|
1188
|
|
POST
|
I have an instance of ArcGIS Server that is still at 9.3, so I needed my geodatabase to stay at 9.3 until we are ready to upgrade. In the mean time, the Oracle DBA needed to upgrade the Oracle to 11g. Since my SDE is very old, a lot of the layers were still in LONG_RAW. I was able to get all my layers copied, migrated, whatever to ST_GEOMETRY. As a last check, I had noticed that in the Upgrade Geodatabase dialog, there was an option to just "Perform Pre-requisite check", without actually doing the upgrade. I figured that would verify that none of my layers still had LONG_RAW, without actually doing any changes, and also verify that I was in good shape once I was ready to actually upgrade to 10. I got several messages in the results, some telling me that I had some locks on the layers (which I didn't expect to see, since I had all my map services stopped) and also a permission error (I wasn't using the SDE administrator). In the end the Upgrade Geodatabase had messages in the Results that it had Failed. Fine, it failed, I was only doing a check anyway. BUT MY GEODATABASE WAS UPGRADED ANYWAY! Now my ArcGIS Server 9.3 can't connect and I"m hoping that a restore from backup fixes this. Is this some sort of 'Known Bug'? Is there maybe just a file that has a flag set that thinks the data is at 10 when it's really not? This was not the expected outcome, especially since the geoprocessing results clearly say that the upgrade failed!
... View more
08-30-2013
12:11 PM
|
0
|
5
|
1707
|
|
POST
|
I agree this is going to be a bumpy transition. I have several projects written a couple years ago, it's not like I have the time to go back and rewrite everything I've done in the past. I think there should be samples in both styles, so we can see the before and after and get the hang of the differences . That API reference is good about showing both, but the samples are a mixed bag. I'd hate to see every sample move to AMD because I need to see both to know where and how to change my older code.
... View more
08-29-2013
06:51 AM
|
0
|
0
|
2576
|
|
POST
|
I decided it was the fact that I was pushing values into an array, along with my row return that was causing my data to 'shift' over one column. Instead of each row of data ending in just '\r', it was ending as \r , (newline followed by a comma). This meant the first string value after the new line was a comma, which forced the whole row over one place. I ended up writing a global replacement for \r , (new row comma) , replacing it with just new row.
var inputData = data.replace(/\n,/g, "\n");//some clean up to get rid of the leading commas in the data
... View more
08-27-2013
07:57 AM
|
0
|
0
|
1225
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-02-2017 02:38 PM | |
| 2 | 03-18-2022 10:14 AM | |
| 2 | 02-18-2016 06:28 AM | |
| 1 | 03-18-2024 07:29 AM | |
| 4 | 08-02-2023 06:08 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-25-2025
01:56 PM
|