|
POST
|
Thanks for the update. I keep trying to use FeatureTable and end up going back to using a plain dGrid. I thought I might be able to manipulate the grid that the FeatureTable is based on, but it doesn't take long to be more trouble than it's worth. Maybe in some future release.
... View more
06-28-2016
11:03 AM
|
0
|
0
|
568
|
|
POST
|
Has this been addressed in subsequent releases? Some of the threads and the documentation for FeatureTable suggest we need to use a query on the underlying grid to filter the data. It makes more sense to me to set a definitionExpression on the underlying FeatureLayer. The variable filterValue is chosen from a filteringSelect. updateTable: function (filterValue) { app.testTable.setDefinitionExpression(("Dist_Code = '" + filterValue + "'"); } In this example, app.testTable is defined as app.testTable = new FeatureLayer (pathName+"/arcgis/rest/services/DHSS/EPHT_radonSchool/MapServer/2", { id: "testTable", outFields: ["*"] }); I'm not sure if I need to also set the table to filterSelectedRecords(true). I'm not getting any errors displayed, but I'm not seeing the results I expected either. In my example, this featureLayer is just a table; it doesn't contain any graphic component to tie back to my map display.
... View more
06-27-2016
11:12 AM
|
0
|
0
|
568
|
|
POST
|
That's what I think I'm doing with domConstruct.empty('schoolSearchDiv'); I'm confused on whether or not I need to create a plain dom 'input' to use before I create my filteringSelect. domConstruct.create("input", {id: 'schoolSelDiv' }, "schoolSearchDiv" ); var mySelect = new FilteringSelect({ id:'schoolSelect', placeHolder: 'Pick one', ignoreCase: true, queryExpr: '${0}*', maxHeight: 200, store: dataStore, searchAttr: 'label' }, "schoolSelDiv"); I hope to catch some error on what I'm calling the new dom elements I'm creating and which I'm telling it to destroy/empty. I am seeing the original filteringselect get removed during domConstruct.empty. It seems to be creating a new empty input DOM element, prior to the new FilteringSelect, but then I'm getting the widget register ID error. Here's a link: Find District by School
... View more
06-24-2016
02:14 PM
|
2
|
0
|
1784
|
|
POST
|
I don't have my services at 10.3, so I can't use the search widget las a find to search through my data. Instead, I'm creating my own version. I want to have an input field that allows the user to enter in part of a school name. Based on the string they enter, I want to display a list of elements that include what they entered. This becomes a filteringselect they can choose from. This works for the first pass. My sequence for destroying the previous filteringselect and creating a new one is off. I thought I could wrap it in a div tag and use domConstruct.empty('searchDivName'). However when I attempt to create a new filteringselect, I'm getting one of those 'Tried to register widget with id XXX, but this is already registered' errors. I thought if I just emptied the div that contained the original filteringselect, I'd be OK. Maybe I'm trying to destroy the wrong element? <div id="toolDiv">
<label for="txtSchool > School Search </label>
<input id="txtSchool" type="text" placeHolder='Enter school' />
<div id="schoolSearchDiv" > </div>
<div id="schoolNote" class="tip" ></div>
</div> event listener on(dom.byId("txtSchool"), "keydown", function(evt){
switch (evt.keyCode){
case keys.ENTER:
var tbVal = evt.target.value
console.log("You entered: " + tbVal );
mySchoolSelect.createSelect(tbVal,app.pointLayer);
break;
default:
}
}); mySchoolSelect.js that executes define ([
"dojo/on",
"dojo/dom",
"dojo/dom-construct",
"dojo/dom-class",
"dojo/_base/array",
"dijit/registry",
"dojo/store/Memory",
"dijit/form/FilteringSelect",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/tasks/FindParameters",
"esri/tasks/FindTask"
], function (
on,dom,domConstruct, domClass, arrayUtils, registry,Memory,FilteringSelect,Query,QueryTask,
FindParameters,FindTask
) {
return {
createSelect: function(tbVal,pointLayer){
domConstruct.empty('schoolSearchDiv');
var selectList = [];
var urlPath = pointLayer.url; //creates the proper url for findtask from a featurelayer url
var urlLen = urlPath.length;
var lastPos = urlPath.lastIndexOf("/");
var findUrl = urlPath.substr(0, lastPos);
var findTask = new FindTask(findUrl);
findParams = new FindParameters();
findParams.returnGeometry = false;
findParams.layerIds = [0];
findParams.searchFields = ['Facility']; //Fields are CASE SENSITIVE
findParams.outSpatialReference = app.spatialReference;
findParams.searchText = tbVal;
findTask.execute(findParams).then(function(results){
if (results.length < 1) {
alert("No matches found for " + tbVal);
dom.byId("schoolNote").innerHTML = "No matches found";
}else {
console.log("You found " + results.length + " matches");
dom.byId("schoolNote").innerHTML = results.length + " matches found, please select one";
domConstruct.create("input", {id: 'schoolSelDiv' }, "schoolSearchDiv" );
selectList.length = 0;
arrayUtils.forEach(results, function(r){
var name = r.feature.attributes.Facility + " - " + r.feature.attributes.City;
var val = r.feature.attributes.CtyDist;
selectList.push({
label: name,
value: val
});
})
selectList.sort(function(item1, item2){
var label1 = item1.label.toLowerCase(), label2 = item2.label.toLowerCase();
return (label1 > label2) ? 1 : (label1 < label2) ? -1 : 0;
});
var dataStore = new Memory({
data: selectList,
idProperty: "value"
});
var mySelect = new FilteringSelect({
id: 'schoolSelect',
placeHolder: 'Pick one',
ignoreCase: true,
queryExpr: '${0}*',
maxHeight: 200,
store: dataStore,
searchAttr: 'label'
}, "schoolSelDiv");
mySelect.startup();
on(mySelect, 'change', function(){
var selectedCode = mySelect.value;
console.log("mySelectchange event, selected value: " + selectedCode);
dom.byId("schoolNote").innerHTML = "";
});
}
});
function errorHandler(err){
console.log("error on populate Dropdown, queryTask, error: " + err.details);
}
}
}
});
... View more
06-24-2016
01:23 PM
|
0
|
6
|
4739
|
|
POST
|
Here's the identify code, 'myIdentify.js, with the statisticdefinitions included. In my case, this is school year data, which spans calendar year. The user wanted the 'startschoolyear' and 'endschoolyear' as separate fields. It didn't make sense to include any of the other statistics available, but I can see how they could easily be included. define([
"dojo/on",
"dojo/_base/array",
"dojo/_base/lang",
"dojo/Deferred",
"esri/InfoTemplate",
"esri/tasks/IdentifyTask",
"esri/tasks/IdentifyParameters",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/tasks/StatisticDefinition",
"esri/geometry/Point",
"esri/geometry/Extent"
], function(
on, arrayUtils, lang, Deferred, InfoTemplate, IdentifyTask, IdentifyParameters, Query, QueryTask,
StatisticDefinition, Point, Extent
) {
return {
runIdentify2: function(point, url) {
app.map.setInfoWindowOnClick(false);
var identifyTask = new IdentifyTask(url);
var identifyParams = new IdentifyParameters();
var def = new Deferred();
app.pt = point;
identifyParams.geometry = point;
identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.layerIds = [0];
var pxWidth = app.map.extent.getWidth() / app.map.width;
var padding = 100 * pxWidth;
var qGeom = new Extent({
"xmin": point.x - padding,
"ymin": point.y - padding,
"xmax": point.x + padding,
"ymax": point.y + padding,
"spatialReference": app.spatialReference
});
identifyParams.geometry = point;
identifyParams.mapExtent = qGeom;
identifyParams.tolerance = 5;
identifyParams.returnGeometry = true;
identifyTask.execute(identifyParams, function(response){
var newFeats = [];
arrayUtils.map(response, lang.hitch(this, function(result, indx) {
var feature = result.feature;
var infoTemplate = new InfoTemplate("Test Results");
createInfoContent(feature).then(lang.hitch(this, function(str){
console.info(str);
infoTemplate.setContent(str);
feature.setInfoTemplate(infoTemplate);
newFeats.push(feature);
console.info(newFeats);
console.info(response.length);
if(indx === response.length - 1){
console.info(newFeats);
app.map.infoWindow.setFeatures(newFeats);
app.map.infoWindow.show(point);
}
}));
}));
});
function createInfoContent(graphic) {
var maindef = new Deferred();
var formatString = "";
var ctyDist = graphic.attributes.CtyDist;
var locTest = graphic.attributes.Loc_Code;
var id = graphic.attributes.SchID;
formatString =
"<b>" + graphic.attributes.Facility + "</b><br/>"
+ graphic.attributes.Address
+ "<br/>" + graphic.attributes.City + ", MO " + graphic.attributes.ZIP;
findSchRelatedRecords(id).then(lang.hitch(this, function(str){
formatString += str;
maindef.resolve(formatString);
}));
return maindef;
}
function findSchRelatedRecords(id) {
var maindef = new Deferred();
var relString = "";
var maxStartStatDef = new StatisticDefinition();
maxStartStatDef.statisticType = "max";
maxStartStatDef.onStatisticField = "SchoolYearStart";
maxStartStatDef.outStatisticFieldName = "latestSchoolYearStart";
var maxEndStatDef = new StatisticDefinition();
maxEndStatDef.statisticType = "max";
maxEndStatDef.onStatisticField = "SchoolYearEnd";
maxEndStatDef.outStatisticFieldName = "latestSchoolYearEnd";
var schQuery = new Query();
var queryTask = new QueryTask(app.testTable.url);
var whereClause = "SchId = '" + id + "'";
schQuery.where = whereClause;
schQuery.returnGeometry = false;
schQuery.outFields = ['*'];
schQuery.outStatistics = [ maxStartStatDef,maxEndStatDef];
queryTask.execute(schQuery, lang.hitch(this, function(results) {
var len = results.features.length;
if (len === 0) {
relString += "<br/>No test results found";
} else {
var latestYearStart = results.features[0].attributes.latestSchoolYearStart;
var latestYearEnd = results.features[0].attributes.latestSchoolYearEnd;
relString += "<br/>Last Year Tested: " + latestYearStart + " / " + latestYearEnd;
}
maindef.resolve(relString);
}));
return maindef;
}
}
};
});
... View more
06-23-2016
08:18 AM
|
0
|
1
|
1538
|
|
POST
|
I had discovered the popup problem after lunch. That was me deleting too many lines of code trying to get minimal lines of code to post as my sample. The other was what I knew I needed to get to, without knowing how to get there. Awesome!
... View more
06-22-2016
01:59 PM
|
0
|
0
|
1538
|
|
POST
|
At this stage I'd be happy if I could get any values out of my related table, whether through a 2nd query or a true relationshipquery. It seems like I ought to be able to come back and add code to find the max year without having to scrap what I've done so far. My identify is setting the content of the infotemplate up to a point, but my sequence is off for getting and adding the extra information from the table. I'm only getting the values from the featurelayer, not the other table. Here's what I have so far. I can attempt to put it in jsbin or something if that makes it easier for someone. Sample Radon Testing - School
... View more
06-22-2016
09:53 AM
|
0
|
1
|
1538
|
|
POST
|
I have a point layer of schools, and a related table of radon tests. I only have one year's worth of test data so far, but the idea is that you could view all tests for a school over the years. What the user requested for the popup is the name of the school and the last year tested. This sounds simple to them, but with the test results all in the related table, not only would you have to reach into the relationship, you'd also have to sort through the results of the year field to find the most recent. Then you'd have to pass that to your popup content. They want to see all the results in a table, which could be in the footer. I'm thinking this could be a featureTable filtered on the results of relationshipQuery? Or maybe just filtered, period. I'll know the school ID and I can limit the table to just those results, I think. At the moment, the related table isn't even set up with a relationship, since they didn't give me a unique ID to tie it together. I sent it back to see if they could do a little more data massage to add it. Instead, I'm attempting to handle this through an identify. I'm still thinking through this. This is called from a map click event: define ([
"dojo/on",
"dojo/_base/array",
"dojo/_base/lang",
"dojo/Deferred",
"esri/tasks/IdentifyTask",
"esri/tasks/IdentifyParameters",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/geometry/Point",
"esri/geometry/Extent"
], function (
on, arrayUtils,lang,Deferred,IdentifyTask,IdentifyParameters, Query,QueryTask, Point,Extent
) {
return {
runIdentify: function(map, url, point){
map.setInfoWindowOnClick(false);
var identifyTask = new IdentifyTask(url);
var idParams = new IdentifyParameters();
var def = new Deferred();
idParams.geometry = point;
idParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
idParams.layerIds = [0];
var pxWidth = map.extent.getWidth() / map.width;
var padding = 100 * pxWidth;
var qGeom = new Extent({
"xmin": point.x - padding,
"ymin": point.y - padding,
"xmax": point.x + padding,
"ymax": point.y + padding,
"spatialReference": app.spatialReference
});
idParams.geometry = point;
idParams.mapExtent = qGeom;
idParams.tolerance = 5;
idParams.returnGeometry = true;
app.cityName = "";
identifyTask.execute(idParams).then(lang.hitch(this, function(results){
var fs = [];
if (results.length > 0) {
arrayUtils.forEach (results, function( result) {
var feature = result.feature;
var formatString = "";
var ctyDist = feature.attributes.CtyDist;
var locTest = feature.attributes.Loc_Code;
var nm = feature.attributes.Facility
formatString = "<b>" + feature.attributes.Facility + "</b><br/>" +
feature.attributes.Address +
"<br/>" +
feature.attributes.City +
", MO " +
feature.attributes.ZIP
var addedString = new Deferred();
addedString = findSchRelatedRecords(nm, ctyDist);
formatString += "<br/>" + addedString;
return feature;
});
app.map.infoWindow.setFeatures([def]);
app.map.infoWindow.show(point);
}
return def;
}));
function findSchRelatedRecords(nm, id){
var relString = " ";
var schQuery = new Query;
var queryTask = new QueryTask(app.testTable.url);
var whereClause = "Facility = '" + nm + "' AND Dist_Code = '" + id + "'";
schQuery.where = whereClause;
schQuery.returnGeometry = false;
schQuery.outFields = ['*'];
queryTask.execute(schQuery, lang.hitch(this, function(results){
var len = results.features.length;
if (len === 0) {
relString += "No test results found";
}
else {
arrayUtils.forEach(results, function(r){
relString += "Start Year: " + r.attributes.ScholYearStart;
});
}
}));
return relString;
}
}
}
});
... View more
06-22-2016
06:21 AM
|
1
|
1
|
1538
|
|
POST
|
I can find very few postings about relationshipQuery and the ones dealing with popups seem very old. Is there anyone attempting to do this?
... View more
06-21-2016
02:49 PM
|
0
|
10
|
4016
|
|
POST
|
I know I need to have some sort of Deferred defined here, but I'm not sure where to insert it. I have a point layer with school names and school districts. I have a table that has the school districts and names again, plus results of testing for radon. I do not have this set up as a relate in my service. Names of schools are not unique across the state, and I have no unique ID provided in that table. Instead, I need to be able to run a query on the table, and before showing the infoWindow, I want to capture the tabular data too and append it to the data coming from the graphic (name, address, city etc). Right now I only have one year's worth of data per school, but there is also the potential for additional years as time goes by. My InfoTemplate definition: //infoTemplates var schoolPtInfoTemplate = new InfoTemplate("Test Results");
schoolPtInfoTemplate.setContent(myInfoTemplate.schoolInfoContent); my pointLayer app.pointLayer = new FeatureLayer (pathName+"/arcgis/rest/services/radonSchool/MapServer/0", {
id: "schoolLayer",
outFields: ["*"],
infoTemplate: schoolPtInfoTemplate
}); //myInfoTemplate define ([
"dojo/dom-construct",
"dojo/on",
"dojo/dom",
"dojo/Deferred" ,
"dojo/_base/array",
"dojo/_base/lang",
"dojo/query",
"dojo/date/locale",
"dojo/number",
"esri/tasks/query",
"esri/tasks/QueryTask",
"js/myRelates"
] , function (domConstruct,on,dom,Deferred,arrayUtils, lang,query,locale,number, Query,QueryTask, myRelates) {
return {
schoolInfoContent: function(graphic){
var currentGraphic = graphic;
var formatString = "";
var oid = graphic.attributes.OBJECTID;
var ctyDist = graphic.attributes.CtyDist;
var locTest = graphic.attributes.Loc_Code;
var nm = graphic.attributes.Facility
formatString ="<b>" + graphic.attributes.Facility + "</b><br/>"
+ graphic.attributes.Address + "<br/>"
+ graphic.attributes.City+ ", MO " + graphic.attributes.ZIP
var addedString = findSchRelatedRecords (nm, ctyDist);
formatString += addedString;
function findSchRelatedRecords (nm, id){
var schQuery = new Query;
var queryTask = new QueryTask(app.testTable.url);
var whereClause = "Facility = '" + nm + "' AND Dist_Code = '" + id + "'";
schQuery.where = whereClause;
schQuery.returnGeometry = false;
schQuery.outFields = ['*'];
queryTask.execute(schQuery, lang.hitch(this,function(results){
var addedString = " ";
var len = results.features.length;
if (len = 0) {
addedString += "No test results found";
}else {
arrayUtils.forEach(results, function (r) {
addedString += "Start Year: " + r.attributes.ScholYearStart;
});
}
})
);
return addedString;
}
return formatString;
}
}
});
... View more
06-21-2016
11:16 AM
|
0
|
0
|
1184
|
|
POST
|
So far so good. I added the code to my extent change handler and the table now contains only the current map extent features. What is controlling the text in the grid header? It states the number of records and the number selected. Limiting the table, the values in the header still reflect the original total number of features.
... View more
06-07-2016
07:26 AM
|
0
|
1
|
1262
|
|
POST
|
You're describing exactly how I always populated my grid, but I'm not seeing that I can get that fine grained when I'm using a featureTable instead. It's a lot more of a closed box in terms of determining what the store/memory is for it, and you don't set up any sort of query for it either. It's more "Here's my featureLayer, how I want the table to display, and my div", and the object takes care getting its own store set up. . The table offered in Web App Builder I believe does let you tie the table to the extent. That functionality hasn't made it's way into the JS API featureTable object, as far as I can tell.
... View more
06-03-2016
02:12 PM
|
0
|
1
|
1262
|
|
POST
|
I have been using a dGrid for a long time and have set them to update on extent change to only list what's shown in the current map extent. I don't see that I have that level of control using FeatureTable. There's interaction from the table to the map, like Zoom to Selection, but nothing that goes the other way, map or layer to control the table. I'd also have a definition expression tool I've added to limit the features on the map that way, and the table isn't honoring that either. Am I missing something, or is that functionality just not available in a FeatureTable? Too bad if it isn't since it means offering something that is faster (FeatureTable) at the expense of loss of functionality.
... View more
06-03-2016
01:32 PM
|
0
|
5
|
4296
|
|
POST
|
I'm glad that was enough of a suggestion to work with. I finished the project I needed this for, leaving it as-is. I'll have to dig back into that code and see if I can add this. I didn't have just one layer that was important, I wanted the information from the layers to appear consistently, basically in the same order I had added them to the map. The concept should still work, though, with modification to your code.
... View more
06-03-2016
01:00 PM
|
2
|
0
|
1832
|
|
POST
|
I never got a resolution myself. I didn't attempt this idea, but I wonder if there would be a way to capture the information before it was displayed, reorder the sequence and then display. I'm not sure what events you'd even be listening for.
... View more
06-03-2016
09:37 AM
|
1
|
1
|
1832
|
| 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
|