プログラムで作成されるdojo.form.FilteringSelect
ウィジェットがにdojo.Dialog
あります。初めて選択してに入力したときに、期待どおりに機能するonChange
イベントをに接続しました。その後、何か新しいものを選択しても、イベントは発生しません。FilteringSelect
FilteringSelect
onChange
ステートメントonChange
にパラメーターを提供するときに、プロパティを宣言しようとしました。new FilteringSelect
を使ってみましたdojo.connect
。私は試しましmySelectDijit.on
た。すべて同じ効果があります。
var select = new dijit.form.FilteringSelect({
id : "fields-select-" + expNum,
store : store,
required : false,
intermediateChanges : true
}, fieldinput);
dojo.connect(select, 'onChange', LoadOperatorValue);
onChange
変更のたびにイベントを発生させるにはどうすればよいFilteringSelect
ですか?
アップデート:
関連するコードを追加しました。このコードは、Dojoを含むArcGIS JavascriptAPIv3.3に基づいています。
dojo.require("dijit.Dialog");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.store.Memory");
dojo.require("dijit.form.MultiSelect");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Textarea");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dijit.form.DateTextBox");
var expNum = 1;
var queryDiv;
var layer;
var dialog;
function CreateDialog(lyr) {
layer = lyr;
queryDiv = dojo.create("div", {
id : "queryDiv"
});
var buttonInput = dojo.create("button", {
id : "button"
}, queryDiv);
var button = new dijit.form.Button({
id : "addExpression",
label : "Add Expression",
onClick : function() {
BuildExpression(layer);
}
}, buttonInput);
BuildExpression(layer)
dialog = new dijit.Dialog({
title : "Query: " + layer.layerObject.name,
content : queryDiv,
style : "width: 600px"
});
dialog.show();
}
function BuildExpression(layer) {
var expDiv = dojo.create("div", {
class : "expression",
id : "expression-" + expNum
}, queryDiv);
var filterDiv = dojo.create("div", {
class : "filter",
id : "filter-" + expNum
}, expDiv);
var fieldSpan = dojo.create("span", {
id : "field-" + expNum,
class : "field"
}, filterDiv);
var operatorSpan = dojo.create("span", {
id : "operator-" + expNum,
class : "operator"
}, filterDiv);
var valueSpan = dojo.create("span", {
id : "value-" + expNum,
class : "value"
}, filterDiv);
var removeSpan = dojo.create("span", {
id : "remove-" + expNum,
class : "remove"
}, filterDiv);
var removeInput = dojo.create("button", {
id : "button"
}, removeSpan);
var removeButton = new dijit.form.Button({
id : "removeExpression" + expNum,
label : "Remove",
onClick : function() {
dojo.destroy(expDiv);
}
}, removeInput);
var fieldinput = dojo.create("input", {
id : "field-input-" + expNum
}, fieldSpan);
var fields = [];
dojo.forEach(layer.layerObject.fields, function(field, index) {
if (index < layer.layerObject.infoTemplate.info.fieldInfos.length && layer.layerObject.infoTemplate.info.fieldInfos[index].visible == true) {
field.operatorSpan = operatorSpan;
field.valueSpan = valueSpan;
fields.push({
name : field.alias,
id : field
});
}
});
var store = new dojo.store.Memory({
data : fields
});
var select = new dijit.form.FilteringSelect({
id : "fields-select-" + expNum,
store : store,
required : false,
intermediateChanges : true
}, fieldinput);
dojo.connect(select, 'onChange', LoadOperatorValue);
expNum++
}
function LoadOperatorValue(field) { debugger;
dojo.empty(field.operatorSpan);
dojo.empty(field.valueSpan);
if ("domain" in field && "codedValues" in field.domain) {
field.operatorSpan.innerHTML = "IS";
var sel = dojo.create("select", {
id : "multiselect-" + expNum
}, field.valueSpan);
dojo.forEach(field.domain.codedValues, function(cv, index) {
dojo.create("option", {
innerHTML : cv.name,
value : cv.code
}, sel);
});
var multiselect = new dijit.form.MultiSelect({}, sel);
} else if (field.type == "esriFieldTypeString") {
var operatorInput = dojo.create("input", {
id : "operator-input"
}, field.operatorSpan);
var operators = [{
name : "IS",
id : " = "
}, {
name : "IS NOT",
id : " <> "
}, {
name : "LIKE",
id : " LIKE "
}, {
name : "NOT LIKE",
id : " NOT LIKE "
}];
var opStore = new dojo.store.Memory({
data : operators
});
var select = new dijit.form.FilteringSelect({
id : "operator-select-" + expNum,
store : opStore,
required : false
}, operatorInput);
var valueInput = dojo.create("input", {
id : "value-input"
}, field.valueSpan);
if (field.length < 50) {
var textBox = new dijit.form.TextBox({
id : "value-input-" + expNum
}, valueInput);
} else {
var textBox = new dijit.form.Textarea({
id : "value-input-" + expNum
}, valueInput);
}
} else if (field.type == "esriFieldTypeDouble" || field.type == "esriFieldTypeSingle" || field.type == "esriFieldTypeInteger" || field.type == "esriFieldTypeSmallInteger") {
var operatorInput = dojo.create("input", {
id : "operator-input"
}, field.operatorSpan);
var operators = [{
name : "=",
id : " = "
}, {
name : "!=",
id : " <> "
}, {
name : "<",
id : " < "
}, {
name : "<=",
id : " <= "
}, {
name : ">",
id : " > "
}, {
name : ">=",
id : " >= "
}];
var opStore = new dojo.store.Memory({
data : operators
});
var select = new dijit.form.FilteringSelect({
id : "operator-select-" + expNum,
store : opStore,
required : false
}, operatorInput);
var valueInput = dojo.create("input", {
id : "value-input"
}, field.valueSpan);
var constraints = {};
if ("domain" in field && "range" in field.domain) {
constraints.min = field.domain.range.min;
constraints.max = field.domain.range.max;
}
if (field.type == "esriFieldTypeDouble" || field.type == "esriFieldTypeSingle") {
constraints.places = 2;
}
var numberSpinner = new dijit.form.NumberSpinner({
id : "value-input-" + expNum
}, valueInput);
} else if (field.type == "esriFieldTypeDate") {
var operatorInput = dojo.create("input", {
id : "operator-input"
}, field.operatorSpan);
var operators = [{
name : "IS",
id : " = "
}, {
name : "IS NOT",
id : " <> "
}, {
name : "Before",
id : " < "
}, {
name : "Before or IS",
id : " <= "
}, {
name : "After",
id : " > "
}, {
name : "After or IS",
id : " >= "
}];
var opStore = new dojo.store.Memory({
data : operators
});
var select = new dijit.form.FilteringSelect({
id : "operator-select-" + expNum,
store : opStore,
required : false
}, operatorInput);
var valueInput = dojo.create("input", {
id : "value-input"
}, field.valueSpan);
var dateTextBox = new dijit.form.DateTextBox({
id : "value-input-" + expNum
}, valueInput);
} else {
}
}