I have a AMD module, which has a public function, to load a feature layer and when the results return I need to populate a grid. I'm having trouble with scope accessing the grid craeted in a private method. I 'm trying to use this.set and watch on the object change , but calling "this.set" gives me a Type error. Please advise, I'm new to dojo framework.
//Constructor function
constructor: function (options, srcRefNode) {
// results holder
this.set("results", []);
// watch updates of public properties and update the widget accordingly
this.watch("results", this._updateMemoryStore);
},
// Update geocoder nodes
_updateMemoryStore: function () {
var items = this.get("results");
//idProperty must be set manually if value is something other than 'id'
var memStore = new Memory({
data: items,
idProperty: "ObjectID"
});
console.log(memStore);
},
onLoadBndry: function() {
...
...
queryTask.disableClientCaching = true;
queryTask.useAMF = false;
queryTask.showBusyCursor = true;
queryTask.execute(query,this._showResults);
},
_showResults:function(featureSet) {
console.log("_showResults");
var items = array.map(featureSet.features, function(feature) {
return feature.attributes;
});
this.set("results", items); \\TypeError: this.set is not a function
},
Hi Priya,
You need to use dojo's lang.hitch on _showResults function call to set the execution scope.
include "dojo/_base/lang" AND
onLoadBndry: function() {
...
...
queryTask.disableClientCaching = true;
queryTask.useAMF = false;
queryTask.showBusyCursor = true;
queryTask.execute(query, lang.hitch(this, this._showResults));
},
You might have to do this for call to _updateMemoryStore as well
this.watch("results", lang.hitch(this, this._updateMemoryStore));
-Girish