EAS BOS F7控件实现多选择并保存原创
金蝶云社区-万成之家
万成之家
15人赞赏了该文章 94次浏览 未经作者许可,禁止转载编辑于2024年11月12日 08:00:06

EAS BOS F7控件实现多选择并保存

1、设置F7开户多选功能

F7.setEnabledMultiSelection(true);

2、除了F7本身字段以外,再添加两个文本字段,F7Name(用于ListUI查询用),F7ID(用于保存多选值),F7自身是不保存数据值的

3、在F7_dataChanged方法里把F7多选到的值分别赋值到F7Name,F7ID中,

例:

protected void f7_dataChanged(

com.kingdee.bos.ctrl.swing.event.DataChangeEvent e) {

      Object[] F7cols = (Object[]) e.getNewValue();

        //Object data = kDLabelExpenseType.getData(); 这样也可以获取到数据,

        //Object[]  F7cols  = (Object[])data;

if (null == F7cols) {

txtF7Name.setText(null);

txtF7ID.setText(null);

SysUtil.abort();

}

StringBuilder f7id = new StringBuilder();

StringBuilder f7Name = new StringBuilder();

for (int i = 0; i < F7cols.length; i++) {

OperationTypeInfo info = (OperationTypeInfo) kOperationType[i];

String idString = info.getId().toString();// 业务类别

operationTypeid.append(idString).append(";");

operationTypeName.append(info.getNumber()).append("-").append(info.getName()).append(";");

}

String operationTypeidValue = operationTypeid.toString();

if (!StringUtils.isEmpty(operationTypeidValue)) {

operationTypeidValue = operationTypeidValue.substring(0,

operationTypeidValue.length() - 1);

txtF7ID.setText(operationTypeidValue);

}

String operationTypeNameValue = operationTypeName.toString();

if (!StringUtils.isEmpty(operationTypeNameValue)) {

operationTypeNameValue = operationTypeNameValue.substring(

0, operationTypeNameValue.length() - 1);

txtF7Name.setText(operationTypeNameValue);

}

}

4、在数据加载的时候,把数据通过ID再解析出来赋值给F7字段  一定要先super.loadFields,再设计f7字段为多选功能,否则这里保存出来的值是内存地址

public void loadFields() {

// 加载

super.loadFields();

f7.setEnabledMultiSelection(true);

String operationTypeID = editData.getOperationTypeID();

if (!StringUtils.isEmpty(operationTypeID)) {

String[] operationType = operationTypeID.split(";");

StringBuilder sbBuilder = new StringBuilder();

EntityViewInfo evi = new EntityViewInfo(); // 创建实体视图

FilterInfo f = new FilterInfo();// 创建过滤对象

for (int i = 0; i < operationType.length; i++) {

FilterItemInfo filter1 = new FilterItemInfo("id",

operationType[i], CompareType.EQUALS);

f.getFilterItems().add(filter1);// 将过滤条件添加到过滤对象中

sbBuilder.append("#").append(i).append(" ").append("or ");

}

String maskString = sbBuilder.toString();

if (!StringUtils.isEmpty(maskString)) {

maskString = maskString.substring(0, maskString.length() - 3);

f.setMaskString(maskString);

evi.setFilter(f);// 设置实体视图的过滤器

try {

IOperationType instance = OperationTypeFactory.getRemoteInstance();

OperationTypeCollection collection = instance.getOperationTypeCollection(evi);

int size = collection.size();

Object[] infoObjects=new Object[size];

for (int i = 0; i < size; i++) {

infoObjects[i]=collection.get(i);

}

f7.setData(infoObjects);

} catch (BOSException e) {

e.printStackTrace();

}

}

}

 


图标赞 15
15人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!