i have two user defined functions.When i declare and call them i get this error.i dont know why it is happening .please help or suggest me how to declare function inside a web app builder widget. Thanks.
startup: function() {
this.inherited(arguments);
var panel = this.getPanel();
panel.position.width = 260;
panel.position.height = 300;
panel.setPosition(panel.position);
panel.panelManager.normalizePanel(panel);
this.FieldsCombo.watch('displayedValue', lang.hitch(this, function(property, oldValue, newValue) {
alert(oldValue+"_________"+newValue);
this.getDistinctValues("https://localhost:6443/arcgis/rest/services/BaseMap/MapServer/"+_strSourceLayer,newValue);---------------------->Error on this line
}));
},
getDistinctValues: function (strURL,strFieldName){
this.getFeatuers(strURL,"1=1", [strFieldName],function(_target){------> Error on this line
for(var i = 0; i < _target.features.length; i++){
var feat=_target.features;
alert(feat[strFieldName]);
}
});
},
getFeatuers: function (URL,where,OUTFields,callback ){
var query = new _Query();
var queryTask = new _QueryTask( URL);
query.where = where;
query.outSpatialReference = _map.spatialReference;
query.returnGeometry = true;
query.outFields = OUTFields;
queryTask.execute(query, callback);
},
});
return clazz;
});
Solved! Go to Solution.
Nadir,
Your biggest problem is non standard widget coding practices. You are coding based on standard JS coding practices. When developing widgets/dijits there are several changes you need to make coding practices.
When calling this.getDistinctValues
onOpen: function() {
console.log('onOpen');
},
onClose: function() {
console.log('onClose');
},
getDistinctValues: function (strURL,strFieldName){
this.getFeatuers(strURL, "1=1", [strFieldName], lang.hitch(this, function(_target){
for(var i = 0; i < _target.features.length; i++){
var feat=_target.features[i];
alert(feat[strFieldName]);
}
}));
},
getFeatuers: function (URL, where, OUTFields, callback){
var query = new _Query();
var queryTask = new _QueryTask( URL);
query.where = where;
query.outSpatialReference = _map.spatialReference;
query.returnGeometry = true;
query.outFields = OUTFields;
queryTask.execute(query, lang.hitch(this, callback));
}
});
});
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.
Nadir,
Your biggest problem is non standard widget coding practices. You are coding based on standard JS coding practices. When developing widgets/dijits there are several changes you need to make coding practices.
When calling this.getDistinctValues
onOpen: function() {
console.log('onOpen');
},
onClose: function() {
console.log('onClose');
},
getDistinctValues: function (strURL,strFieldName){
this.getFeatuers(strURL, "1=1", [strFieldName], lang.hitch(this, function(_target){
for(var i = 0; i < _target.features.length; i++){
var feat=_target.features[i];
alert(feat[strFieldName]);
}
}));
},
getFeatuers: function (URL, where, OUTFields, callback){
var query = new _Query();
var queryTask = new _QueryTask( URL);
query.where = where;
query.outSpatialReference = _map.spatialReference;
query.returnGeometry = true;
query.outFields = OUTFields;
queryTask.execute(query, lang.hitch(this, callback));
}
});
});
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.