【发布时间】:2017-06-24 10:25:42
【问题描述】:
我正在扩展使用 here 的 fill 函数以使用选择字段选项填充 <select> 元素,以便处理搜索字段。
我的表单中有两个 <select> 元素,STATDES(选择)和 OWNERLOGIN(搜索)。
<div id="container" onchange="fieldChangeHandler(event)">
...
<div class="item" >
<label>Status</label>
<select id="STATDES" onfocus="focusdiv(event)" onblur="defocusdiv(event)"></select>
</div>
<div class="item" >
<label>Assigned to</label>
<select id="OWNERLOGIN" onfocus="focusdiv(event)" onblur="defocusdiv(event)"></select>
</div>
我正在检查column 的zoom 属性以确定我是否应该从searchObj.ChooseLine 或searchObj.SearchLine 对象中读取。
function fill(el, sel){
switch (myForm.columns[el.id].zoom){
case "Choose":
myForm.choose(el.id, sel).then(
function (searchObj) {
var i, ch;
$('#'+el.id).empty();
for (i in searchObj.ChooseLine) {
ch = searchObj.ChooseLine[i];
if (ch.string1 == sel){
$("#"+el.id).append('<option selected value="'+ ch.string1 +'">'+ ch.string1 +'</option>');
} else {
$('#'+el.id).append('<option value="'+ ch.string1 +'">'+ ch.string1 +'</option>');
};
};
},
showMessage
);
break;
case "Search":
myForm.choose(el.id, sel).then(
function (searchObj) {
var i, ch;
$('#'+el.id).empty();
for (i in searchObj.SearchLine) {
ch = searchObj.SearchLine[i];
if (ch.string2 == sel){
$("#"+el.id).append('<option selected value="'+ ch.string2 +'">'+ ch.string2 +'</option>');
} else {
$('#'+el.id).append('<option value="'+ ch.string2 +'">'+ ch.string2 +'</option>');
};
};
},
showMessage
);
break;
};
};
STATDES 上的 choose 函数返回一个 searchObj.ChooseLine 对象。
OWNERLOGIN 上的 choose 函数返回一个 searchObj.SearchLine 对象。
但是两者都有Choose的缩放类型。
myForm.columns['STATDES']{
attachment: 0
decimal: 0
field: 5
format: ""
mandatory: 1
maxLength: 12
readonly: 0
title: "Status"
type: "text"
zoom: "Choose"
}
myForm.columns['OWNERLOGIN']{
"attachment": 0,
"decimal": 0,
"field": 6,
"format": "",
"mandatory": 1,
"maxLength": 20,
"readonly": 0,
"title": "Assigned to",
"type": "text",
"zoom": "Choose"
}
请问如何区分?
【问题讨论】:
-
你能用
title属性区分吗? -
谢谢,但不,因为
title可以是任何东西,具体取决于表单中动态包含哪些列。我需要能够根据zoom属性确定如何处理列。 -
您可以为其添加自定义键吗?您可以稍后检查以分类哪种类型。
-
恐怕同样的问题。如果我要添加自定义类型,我需要知道要设置它的
zoom类型。myForm.columns['OWNERLOGIN'].customkey=? -
问题是你在你的 switch case 中检查
myForm.columns[el.id].zoom,你说的是Choose作为这两种类型的值。必须有一些唯一的标识符,否则你的开关盒就没用了。
标签: javascript erp