I'm working with arcgis Javascript Api 3.7 (wich includes dojo 1.9.1), and I have been developing a custom templated dijit that has two filteringSelect controls, the first one gets pupulated correctly, and i have a second one that gets populated when the user selects one item from the first one setting its data store at that particular moment. this second filteringSelect gets correctly populated everytime, but something happens with the onchange event, because the function handler never gets fired, I need to do some other staff on the onchange event of the second FilterinSelect.
It seems something gets messed up with the second filteringSelect (guessing something with the handler context) but I can't figure it out yet.
My two filtering controls template declaration (part of my dijit html template:
<tr>
<td>
Capa:
</td>
<td>
<input data-dojo-type="dijit.form.ComboBox" name="layerDijit" id="layerDijit"
data-dojo-props="autoComplete:true, required:true, searchAttr:'name', style:'width:100%;'"
data-dojo-attach-point="layerDijit" data-dojo-attach-event="change:_handleLayerSelected"/>
</td>
</tr>
<tr>
<td>
Campo:
</td>
<td>
<input data-dojo-type="dijit.form.FilteringSelect" name="fieldDijit" id="fieldDijit"
data-dojo-props="autoComplete:true, required:true, searchAttr:'name', style:'width:100%;'"
data-dojo-attach-point="fieldDijit" data-dojo-attach-event="change:_handleFieldSelected"/>
</td>
</tr>
Dijit JS Script:
The code that populates the first Filtering Select
postCreate: function() {
this.inherited(arguments);
....
this.rootMapLayer = this.map.getLayer("ELAPAS");
if (this.rootMapLayer.loaded){
this.listLayers(this.rootMapLayer);
}
else{
this.rootMapLayer.on("load", lang.hitch(this, this.listLayers));
}
//enlace de eventos (tested this, and it doesn't work for the second filtering select either)
//this.fieldDijit.on('change', lang.hitch(this, this._handleFieldSelected));
//this.layerDijit.on('change', lang.hitch(this, this._handleLayerSelected));
},
listLayers: function() {
var layerInfos = [];
layerInfos = array.filter(this.rootMapLayer.layerInfos,function(info,index){
return info.subLayerIds === null;
});
if(layerInfos.length === 0) {
console.error("No se encontro ninguna capa para el servicio de mapa seleccionado");
return;
}
var layersStore = new Memory({
data: layerInfos
});
this.layerDijit.set('store', layersStore);
},
The code that handles the selection change in the first filteringSelect called layerDijit and loads the data for the second one (FieldDijit):
_handleLayerSelected: function () {
var selectedLayer = this.layerDijit.item;
if(this.getSelectedLayerUrl() === null) {
return;
}
//Se limpia el campo actual
this.fieldDijit.set("value", "");
//Se arma la url del layer específico para traer la información de la capa (sus campos)
var layerUrl = this.rootMapLayer.url + "/" + selectedLayer.id;
esri.request({
url: layerUrl,
content: {
f: "json"
},
handleAs: "json",
callbackParamName: 'callback',
load: lang.hitch(this, '_handleLayerInfo'),
error: lang.hitch(this, '_handleLayerInfoError')
});
},
_handleLayerInfo: function(data) {
var layerInfo = data;
if (!layerInfo.fields) {
console.error("No se pudo obtener la información de los campos de la capa");
return;
}
var fieldsStore = new Memory({
data: layerInfo.fields
});
this.fieldDijit.set('store', fieldsStore);
},
getSelectedLayerUrl: function(){
var selectedLayer = this.layerDijit.item;
if(!selectedLayer) {
return null;
}
//Se arma la url del layer específico para traer la información de la capa (sus campos)
return this.rootMapLayer.url + "/" + selectedLayer.id;
},
_handleLayerInfoError: function(err){
console.error(err);
},
The function that doesn't get fired, the one that is supossed to handle se change event of the second filtering select:
_handleFieldSelected: function () {
alert("doesn't get fired");
/*var selectedField = this.fieldDijit.item;
if(!selectedField) {
return;
} */
},
Could you give me some advice about this problem?, What am I doing wrong?.
Thanks in advance