新增:
新增时:
onShow:
var dataSetDictionary=view.get("#targetDisplayDataSetDictionary");
var targetDisplayContainer=view.get("#targetDisplayContainer");
var entityList=dataSetDictionary.getData();
var count = 2;
var hContainer = new dorado.widget.Container({layout: "HBox",height:0});
targetDisplayContainer.addChild(hContainer);
entityList.each(function(entity){
if (count % 10 == 0) {
hContainer = new dorado.widget.Container({layout: "HBox",height:40});
targetDisplayContainer.addChild(hContainer);
}count++;
var enumKey = entity.get("key");
var enumValue = entity.get("value");
hContainer.addChild(new dorado.widget.CheckBox({
caption: enumValue,
value: enumKey,
tags: "dutyName",
checked:false,
onValue: enumKey,
offValue: 0,
width : 100
}));
})
编辑时,自动填充已经勾选的值:
editDialog对话框的onShow事件中增加:
var dataSetDictionary=view.get("#targetDisplayDataSetDictionary");
var targetDisplayContainer=view.get("#targetDisplayContainerUpdate");
targetDisplayContainer.removeAllChildren();
var entityList=dataSetDictionary.getData();
//var textTag=view.get("#dataSetExplosiveTagDetail").getData("#");
var entity = view.get("#dgRoleDuty").getCurrentItem();
if(isEmpty(entity)){
dorado.MessageBox.alert("请选择一行数据进行修改!");
}
var dutyOrganizationId = entity.get('dutyOrganizationId');
function findInArray(value){
try {
var targetDisplayIds=null;
if(!isEmpty(dutyOrganizationId)){
targetDisplayIds = dutyOrganizationId.split(",");
}
//textTag.get("targetDisplay");
if(isEmpty(targetDisplayIds)){
return -1;
}
return jQuery.inArray(value,targetDisplayIds);
} catch (e) {
return -1;
}
}
var count = 2;
var hContainer = new dorado.widget.Container({layout: "HBox",height:0});
targetDisplayContainer.addChild(hContainer);
entityList.each(function(entity){
if (count % 10 == 0) {
hContainer = new dorado.widget.Container({layout: "HBox",height:40});
targetDisplayContainer.addChild(hContainer);
}count++;
var enumKey = entity.get("key");
var enumValue = entity.get("value");
findInArray(enumValue);
hContainer.addChild(new dorado.widget.CheckBox({
caption: enumValue,
value: enumKey,
tags: "dutyName",
checked: (findInArray(enumKey) == -1)? false : true,
onValue: enumKey,
offValue: 0,
width : 100
}));
})
function isEmpty(obj){
if(typeof obj == "undefined" || obj == null || obj == ""){
return true;
}else{
return false;
}
}
保存:
var targetDisplay= view.get("^dutyName");
var targetDisplayNameArray = [];
targetDisplay.each(function(data){
if(data.get("checked")){
targetDisplayNameArray.push(data.get("value"));
}
});
targetDisplayNameIds = targetDisplayNameArray.join(",");
entity.set("dutyName",targetDisplayNameIds);