|
POST
|
I finally figured it out! I finally noticed that my Memory was declared as the class ContentPane. That wasn't right! So I sorted out my requires etc and now it is working. That is by far the most klunky aspect to using AMD.
... View more
09-30-2013
08:10 AM
|
0
|
0
|
2233
|
|
POST
|
That example works. Now I have to figure out how to do this more dynamically because I have to generate the list from a function. There are hundreds of school district names. I don't have any "dojo/_base/declare" in my code. I'm not sure what that does. Maybe that's what I'm missing.
... View more
09-30-2013
07:56 AM
|
0
|
0
|
2233
|
|
POST
|
On 2nd thought that's not going to work, because 'label' probably doesn't exist until it runs through my populateDropdownList function. I changed it to this. Still doesn't work, though.
function resultsHandler(results){
var select = registry.byId("distSelect");
districtList.length = 0;
var numResults = results.featureSet.features.length;
for (var j = 0; j < numResults; j++) {
var distName = results.featureSet.features .attributes.DIST_NAME;
var distCode = results.featureSet.features .attributes.DIST_CODE;
districtList.push({label: distName, value: distCode});
}
districtList.sort(function(item1, item2) {
var label1 = item1.name.toLowerCase(),
label2 = item2.name.toLowerCase();
return (label1 > label2) ? 1 : (label1 < label2) ? -1 : 0;
});
var dataStore = new Memory({data:districtList, idProperty:"value"})
select.set ("store", dataStore);
select.set ("labelAttr", "label");
select.set ("searchAttr", "value");
// select.addOption(districtList);
console.log (districtList);
}
... View more
09-27-2013
12:48 PM
|
0
|
0
|
2233
|
|
POST
|
They were not. This started out as a simple Select and all I did was switch the type to FilteringSelect.
<select id="distSelect" data-dojo-type="dijit/form/FilteringSelect"
data-dojo-props="title:'Find schools in selected district',maxHeight:200, size: 30, labelAttr:'label', searchAttr:'label'">
<option>Pick a district</option>
</select>
This must not be right. I'm getting an error TypeError: _32[this.searchAttr] is undefined Like I mentioned, this is my first AMD, so I'm a little uncertain on syntax.
... View more
09-27-2013
12:36 PM
|
0
|
0
|
2233
|
|
POST
|
When I look at the dojo example for using a datastore for a filteringselect, they are using name and id, not label and value, so I thought maybe that was the problem.
var stateStore = new Memory({
data: [
{name:"Alabama", id:"AL"},
{name:"Alaska", id:"AK"},
{name:"American Samoa", id:"AS"},
{name:"Arizona", id:"AZ"},
{name:"Arkansas", id:"AR"}
]
});
So I change what I was pushing to my districtList:
districtList.push({name: distName, id: distCode});
But it didn't help ...
... View more
09-27-2013
12:25 PM
|
0
|
0
|
2233
|
|
POST
|
There must be something about the objects in the data store. If I look at what's in districtList, it contains label and value. So I thought maybe the issue was that idProperty should be value, not DIST_CODE.
var dataStore = new Memory({data:districtList, idProperty:"value"})
Setting a breakpoint, I can see that select dijit goes from having just one entry in the 'store' value of "Pick a district" to a long list, starting with Object { label="Adair Co. R-I", value="001090"}. idProperty is defined as value. Should I not have quoted it? It seems like it should be. It looks to me like the store is getting set, but it's not the right format so it still doesn't work as a dropdown.
... View more
09-27-2013
12:10 PM
|
0
|
0
|
2233
|
|
POST
|
There are no values in my Select and when I click on it, I get an error TypeError: _f.store.query is not a function. Could it be something different than idProperty?
... View more
09-27-2013
11:41 AM
|
0
|
0
|
2934
|
|
POST
|
I know this must be the right path to follow, but so far it's not working. I added the reference for Memory. Most examples I find people are using the querytask to populate a grid. But in this case I'm trying to populate the store of a FilteringSelect. I don't know if I need to define my store or data differently because of that. I know in some instances I need to have an identifier as part of my data definition. But maybe that's for ItemFileReadStore and grids and doesn't apply in this situation.
function resultsHandler(results){
var select = registry.byId("distSelect");//my filteringSelect dijit
districtList.length = 0;
var numResults = results.featureSet.features.length;
for (var j = 0; j < numResults; j++) {
var distName = results.featureSet.features .attributes.DIST_NAME;
var distCode = results.featureSet.features .attributes.DIST_CODE;
districtList.push({label: distName, value: distCode});
}
districtList.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:districtList});
select.set ("store", dataStore);
// select.addOption(districtList);
}
... View more
09-27-2013
11:02 AM
|
0
|
0
|
2934
|
|
POST
|
I'm using dijit/form/Select, thinking it would let the user enter a letter on the keyboard and jump to that position in the list. Apparently I need FilteringSelect instead. The problem is the syntax for populating the options is not the same at all between the two types of Select. I don't see anywhere in the reference for filteringSelect how I can do this.
... View more
09-27-2013
10:31 AM
|
0
|
0
|
2934
|
|
POST
|
I'm not really getting an error. That would be too easy! I've set a breakpoint at the top of the if (results) statement and just start stepping through. I get a value for feature, it says it's class of esri.Graphic, but when I step to the definition of graphic, it takes me into what looks like the ESRI TimeReference.js . This has been happening to me lately every time I try to define something improperly! Same location, no matter what my error is. I have the same code in a non-AMD project and it works just fine there. I can't help but think I'm not requiring the right components, or just not the right way. This is my first attempt using AMD and I'm keep getting lost in the weeds of syntax.
... View more
09-27-2013
08:39 AM
|
0
|
0
|
1425
|
|
POST
|
I have a query that executes to populate a dGrid. I'd like to be able to click on a row in the grid and highlight the feature on the screen. Since the row doesn't have any knowledge of the geometry, I have a 2nd query. This query is executing just fine, but I'm having troubles creating the graphic and adding it to either the map graphics or a graphicsLayer. I don't much care which, I think my problem is in the definition of the graphic I haven't been using AMD very long, so maybe I'm getting a little lost there. I'm confused by the fact that some examples and API references show dojo.require of "esri/graphic" and others are "esri/Graphic". Is that just an error? Only esri/graphic seems to work. Plus the API reference for Graphic lists geometry, symbol, attributes and infoTemplate all as required elements in the constructor. But lots of examples only have geometry and symbol or even just geometry. Why all the inconsistency?
function highlightGridSelection(event, dGrid) {
selGraphicsLayer.clear();
var row = dGrid.row(event);
var query = new esri.tasks.Query();
var schName = [row.data.facility];
var cityName = [row.data.city];
query.where = "Facility = '" + schName + "' and " + "City = '" + cityName + "'";
query.returnGeometry = true;
query.outFields = ["*"];
query.outSpatialReference = spatialReference;
var queryTask = new esri.tasks.QueryTask(educationLayer.url+"/0");
queryTask.execute(query, highlightResults);
}
function highlightResults(results) {
if (results) {//Note: I am consistently getting results from the query task, it's not like it's blank
var feature = results.features[0];//already esri.Graphic?
var graphic = new Graphic(feature.geometry, highlightMarkerSymbol); //this seems to be the problem line
selGraphicsLayer.add(graphic);//
// app.map.graphics.add(graphic);
} else {
console.log("No records found");
}
}
... View more
09-27-2013
08:04 AM
|
0
|
5
|
2766
|
|
POST
|
The problem looks to be with the difference between an array and an object. I had data defined as an array and IE didn't like that. I changed this to: function createSchoolList (results) {
var resultsLength = results.featureSet.features.length;
var schoolList = {};
if (dGridStacked) {
dGridStacked.refresh();
}
if (dGridTable) {
dGridTable.refresh();
}
schoolList.data = arrayUtils.map(results.featureSet.features, function(feature){
return {
"facility": feature.attributes["Facility"],
"address": feature.attributes["Address"],
"city": feature.attributes["City"]
};
});
dGridStacked = new dgrid.Grid({
renderRow: renderRowFunction,
showHeader: true
}, "searchResultsGrid");
dGridStacked.startup();
dGridStacked.renderArray(schoolList.data);
dGridStacked.sort('facility');
dGridStacked.on('.dgrid-row:click', function(event){
highlightGridSelection(event, dGridStacked);
});
queryDistrict();
}
This works OK in IE.
... View more
09-27-2013
07:53 AM
|
0
|
0
|
1725
|
|
POST
|
This works fine in Firefox, but testing it in IE, which is still the state's standard browser gives an error on the line that is defining the data variable: Expected identifier, string or Number. I assume that data is an object and IE doesn't like it?
... View more
09-27-2013
05:55 AM
|
0
|
0
|
1725
|
|
POST
|
That was part of it. The other part was invalid syntax getting each value on the attributes. I'm not sure where I got the idea I needed square brackets. Maybe in another scenario that's appropriate. It should be: data = arrayUtil.map(results.featureSet.features, function(feature){ return { 'facility': feature.attributes.Facility, 'address': feature.attributes.Address, 'city': feature.attributes.City, };
... View more
09-26-2013
10:20 AM
|
0
|
0
|
1725
|
|
POST
|
I copied this from an existing project which processes results from a selectFeatures request on a featureLayer instead of from a queryTask. There it works properly without the column definitions you're suggesting. I really don't think that's the problem.
... View more
09-26-2013
08:51 AM
|
0
|
0
|
1725
|
| 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
|