一、多选基础资料
1. 取值:
// 取值:多选基础资料字段值,DynamicObjectCollection 类型
DynamicObjectCollection rows = (DynamicObjectCollection)this.getModel().getValue("mulbasedatafield");
for (DynamicObject row : rows){
DynamicObject basedataObj = (DynamicObject)row.getDynamicObject("fbasedataid");
//获取多选基础资料种基础资料的id
Long basedataId = (Long) basedataObj.getPkValue();
}
2. 赋值:需要传入DynamicObjectCollection或者主键集合Object[]
1)传入DynamicObjectCollection,可以根据需要先获取rows
this.getModel().setValue("mulbasedatafield", rows);
2)方法2:传入Object[],可以根据需要先获取到基础资料的id
QFilter qFilter = new QFilter("number", "=", "001");
//查询指定的基础资料的id
DynamicObjectCollection data = QueryServiceHelper.query("biaoshi", "id", new QFilter[] {qFilter});
Long pid = (Long) data.get(0).get("id");
Object[] basedataIds = new Object[] {pid};
this.getModel().setValue("mulbasedatafield", basedataIds);
二、下拉列表
取值:有时候不仅要获取下拉列表的下拉值,还要获取到下拉标题
// 自行到主实体模型中获取
MainEntityType mainType = this.getModel().getDataEntityType();
ComboProp comboProp = (ComboProp) mainType.getProperties().get("combofield");
List<ValueMapItem> combodata = comboProp.getComboItems();
获取下拉列表的第一条数据
ValueMapItem valuedata = combodata.get(0);
//下拉列表第一条数据的下拉标题
String name = valuedata.getName().toString();
//下拉列表第一条数据的下拉值
String value = valuedata.getValue();
赋值:动态设置下拉列表值
List<ComboItem> comboItems = new ArrayList<>();
ComboItem comboItem = new ComboItem();
comboItem.setCaption(new LocaleString("test3"));
comboItem.setValue("3");
comboItems.add(comboItem);
comboItem = new ComboItem();
comboItem.setCaption(new LocaleString("test4"));
comboItem.setValue("4");
comboItems.add(comboItem);
//和控件绑定
ComboEdit comboEdit = this.getControl("combofield");
comboEdit.setComboItems(comboItems);
推荐阅读