移动表单下拉列表赋值异常
金蝶云社区-新垣结衣
新垣结衣
0人赞赏了该文章 891次浏览 未经作者许可,禁止转载编辑于2016年04月20日 15:28:55

背景:有2个下拉列表A,B。A列表选择项变更时从数据库获取数据,填充到B列表,先发现问题:

1.当EnumItem的Caption包含-符号时,后面的内容会被截取掉,比如 AA-BB 就会变成 AA
2.当EnumItem的Value包含非数字的字符串时,整个列表就不会有内容

PS:当在AfterBindData事件处理时,以上问题均不会出现,只有在值更新事件或者单据事件时,才会发生以上问题。


以上,请帮忙看下是否为bug还是代码有问题,谢谢


代码如下,Python和C#代码都试过了,一样的

count=0
def DataChanged(e):
if e.Key.lower()=="F_PAEZ_Combo".lower(): #会有如上所述情况
changecombo()

def AfterBindData(e):
changecombo() #不会有问题

def changecombo():
global count
count=count+1
newList = List[EnumItem]()
for i in range(10*count,10*count+7):
newItem = EnumItem();
newItem.Seq=i;
newItem.Value = "{0}".format(i);
newItem.Caption =LocaleValue("value({0})".format(i));
newList.Add(newItem);
fieldEditor = this.View.GetControl("FSystem")
fieldEditor.SetComboItems(newList)

C#代码 public class xxxxx : AbstractMobilePlugin {
private int count = 0;

public override void AfterBindData(EventArgs e) {#不会有问题
initComboboxs();
}

public override void DataChanged(DataChangedEventArgs e) {#会有问题
if (e.Field.Key.EqualsIgnoreCase("F_PAEZ_Combo")) {
initComboboxs();
}
}

private void initComboboxs() {
count++;

var lst = new List();
for (int i = count*10; i < count*10 + 7; i++) {
var item = new EnumItem();
item.Seq = i;
item.Value = i.ToString();//赋值如:"AAA"就有问题
item.Caption = new LocaleValue("value-" + i.ToString());//带-就有问题
lst.Add(item);
}
this.View.GetControl("FSystem").SetComboItems(lst);
}
}
}