基本方法
修改绑定事件
this.connects.push(dojo.connect(this.parkingStyle, "onChange", this, this.onClick_parkingStyle));
设置下拉框为不可编辑
this.selEnterType.domNode.onkeydown = function(){return false;};
取值
//输入框内文字内容
var getDisplayedValue = this.assetType.getDisplayedValue();
assetFactory = this.assetSupFactory.attr("displayedValue");
//value值,例如“-1”
var getValue = this.assetType.getValue();
assetFactoryId = this.assetSupFactory.attr("value");
jQuery - option的值
获取值
$("#equip_show").change(function(){
//获取文本
var checkText = $("#equip_show").find("option:selected").text();
console.info("text:",checkText);
var checkValue = $("#equip_show").val();//获取value值
console.info("value:",checkValue);
});
设置值
$("#select_id ").get(0).selectedIndex=1; //设置Select索引值为1的项选中
$("#select_id ").val(4); // 设置Select的Value值为4的项选中
$("#select_id option[text='jQuery']").attr("selected", true); //设置Select的Text值为jQuery的项选中
模板
模板1:动态建立下拉框
Html
<div class="col-xs-3">
<div dojoAttachPoint="laneNum" required="true"></div>
</div>
Js
//初始化
initLaneNo:function(){
var items = [];
var all = [];
all.id = -1;
all.code = this.nls.ALL;
items.push(all);
var store = new dojo.data.ItemFileWriteStore({
data:{
identifier: "id",
label: "code",
items: items
}
});
this.laneNumValue = new bootstrap.form.FilteringSelect({
store: store,
searchAttr: "code",
flowHeight:"300" //下拉框长度,可不要
}, this.laneNum);
if(store._jsonData.items.length > 0){
this.laneNumValue.attr("displayedValue",store._jsonData.items[0].code);
}
},
//初始化时,直接赋写死的值
initDeviceType:function(){
var items = [];
items.push({id:-1, code:this.nls.ALL});
items.push({id:1, code:"524"});
var store = new dojo.data.ItemFileWriteStore({
data:{
identifier: "id",
label: "code",
items: items
}
});
this.deviceTypeValue = new bootstrap.form.FilteringSelect({
store: store,
searchAttr: "code"
}, this.deviceType);
//默认选中全部
if(store._jsonData.items.length > 0){
this.deviceTypeValue.attr("displayedValue",store._jsonData.items[0].code);
}
},
//清空重新赋值
this.laneNumValue.store = [];
var items = [];
var all = [];
all.id = -1;
all.code = this.nls.ALL;
items.push(all);
for(var i = 0; i < json.content.length; i++){
items.push(json.content[i]);
}
var store = new dojo.data.ItemFileWriteStore({
data:{
identifier: "id",
label: "code",
items: items
}
});
this.laneNumValue.store = store;
this.laneNumValue.attr("displayedValue", this.nls.ALL);
//赋值
gaCom.getPlateType = function(){
var json = [];
json.push({id:-1, caption:"全部"});
json.push({id:01, caption:"大型汽车号牌"});
json.push({id:02, caption:"小型汽车号牌"});
json.push({id:03, caption:"使馆汽车号牌"});
return json;
};
模板2:天地 - 车牌号码 - 下拉框
html
<!-- 车牌号码 -->
<label class="col-xs-1 control-label">
${nls.PLATE}
</label>
<div class="col-xs-3 col-no-padding">
<div class="col-xs-3 input-group-sm col-no-padding">
<input dojoAttachPoint="platNumType" />
</div>
<div class="col-xs-8 input-group-sm col-no-padding">
<input dojoType="bootstrap.form.ValidationTextBox" type="text" dojoAttachPoint="platNum" regExp=${nls.REGEXP_EX.FILTER_PLATE} invalidMessage="${nls.PLEASE_ENTER_VAILD_VALUE}" maxLength="11"/>
</div>
</div>
js
//车牌号码 - 下拉框
onChange_selectPateNum:function(){
var platNumType = this.platNumTypeInput.attr("displayedValue");
this.platNum.attr("displayedValue",platNumType);
},
//加载车牌下拉框信息
initSelect:function(){
var store =visCom.plateNumStore();
this.platNumTypeInput = new bootstrap.form.FilteringSelect({
store: store,
searchAttr: "caption",
style:"width:100%;"
}, this.platNumType);
if(store._jsonData.items.length > 0){
dojo.xhrPost({
url: visCom.webServicePath + "itsUserCustomize/query",
sync: true,
content: {},
preventCache: true,
load: dojo.hitch(this, function(response, ioArgs){
var json = dojo.fromJson(response);
this.platNumTypeInput.attr("displayedValue",json.content.area_short_name);
}),
error: function(response, ioArgs){
console.error(response, ioArgs);
}
});
}
var platNumType = this.platNumTypeInput.attr("displayedValue");
this.platNum.attr("displayedValue",platNumType);
//下拉框只加载一次
this.connects.push(dojo.connect(this.platNumTypeInput, "onChange",dojo.hitch(this, this.onChange_selectPateNum)));
},
模板3:车牌号码 - PPIS下拉框
html
<div class="col-xs-3">
<div dojoAttachPoint="plateType" required="true"></div>
</div>
js
//初始化 - 号牌种类
initPlateType:function(){
this.plateTypeValue = gaCom.creatSltOption(gaCom.getPlateType(this.nls, false),this.plateType);
this.plateTypeValue.attr("value", -1);
},
//下拉框修改绑定方法
this.connects.push(dojo.connect(this.plateTypeValue, "onChange", this, this.onChange_divPlateType));//号牌种类 - 下拉框
common.js
//号牌种类
gaCom.getPlateType = function(nls,needAll) {
var json = [];
if(needAll){
json.push({id: -1, caption:nls.ALL});
}
json.push({id:-1, caption:"全部"});
json.push({id:01, caption:"大型汽车号牌"});
json.push({id:02, caption:"小型汽车号牌"});
json.push({id:03, caption:"使馆汽车号牌"});
var data = {
identifier: "id",
label: "caption",
items: json
};
var store = new dojo.data.ItemFileWriteStore({
data: data
});
return store;
};
备注:当id重复时,下拉框报错,无法使用
模板4:Html直接写死值
//value="0" 表示选中value="0"的项
<select dojoType="bootstrap.form.FilteringSelect" dojoAttachPoint="sltNocDiaVideoResult" value="0">
<option value="0">${nls.ALL_DEVICE}</option>
<option value="1">${nls.ERROR_DEVICE}</option>
</select>
//选中值
this.sltNocDiaVideoResult.setValue(0);