EAS BOS F7 过滤 动态 级联 详细使用

文经过几个小例子来说解金蝶EAS BOS 开发F7控件的过滤使用;java

一、新建一张业务单据,存在两个F7控件,基本库位属于仓库,只有选择了仓库才,能肯定库位。发布业务单元,以下:app

二、打开JAVA视图,找到EDITUI JAVA文件,新增方法ide

  a)首先为仓库添加过滤,prmtwarehouse为仓库F7,并添加监听事件。ui

 
private void initF7() {
		EntityViewInfo entityView = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		 filter.getFilterItems().add(new
		 FilterItemInfo("number","A2%",CompareType.LIKE));
		entityView.setFilter(filter);
		prmtwarehouse.setEntityViewInfo(entityView);
		prmtwarehouse.addDataChangeListener(new DataChangeListener() {
			public void dataChanged(DataChangeEvent e) {
				datachangeAction_dataChanged(e);
			}
		});
	}

  b)为库位添加过滤,prmtlocationhouse为库位F7;并根据F7是否存在可选项,进行必输、默认值设置;this

private void locationhouseF7(String warehouseid) {
		EntityViewInfo entityView = locationhouseF7Judge(warehouseid);
		prmtlocationhouse.setEntityViewInfo(entityView);
		try {
			LocationCollection local = LocationFactory.getRemoteInstance()
					.getLocationCollection(entityView);

			if (local.size() > 0) {
				prmtlocationhouse.setRequired(true);
				prmtlocationhouse.setValue(local.get(0));
			} else {
				prmtlocationhouse.setRequired(false);
			}
		} catch (BOSException e1) {
			e1.printStackTrace();
		}
	}
	private EntityViewInfo locationhouseF7Judge(String warehouseid) {
		EntityViewInfo entityView = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		filter.getFilterItems().add(
				new FilterItemInfo("WAREHOUSE.id", warehouseid,
						CompareType.EQUALS));
		entityView.setFilter(filter);
		return entityView;
	}

  c)新增仓库F7更新事件方法code

public void datachangeAction_dataChanged(DataChangeEvent e) {
		try {
			Object source = e.getSource();

			if ((e.getOldValue() != null)
					&& (e.getOldValue().equals(e.getNewValue()))) {
				return;
			}
			if (this.prmtwarehouse.equals(source)) {
				if (e.getNewValue() == null) {
					prmtlocationhouse.setValue(null);
					locationhouseF7(null);
				} else {
					String warehouseid = ((WarehouseInfo) e.getNewValue())
							.getId().toString();
					prmtlocationhouse.setValue(null);
					locationhouseF7(warehouseid);
				}

			}
		} catch (Exception exc) {
			handUIException(exc);
		}
	}

  d)重写verifyInput(ActionEvent e)方法进行必输项验证blog

@Override
	protected void verifyInput(ActionEvent e) throws Exception {
		EntityViewInfo entityView;
		if(com.kingdee.bos.ui.face.UIRuleUtil.isNull(editData
				.getWarehouse())){
			entityView = locationhouseF7Judge(null);
		}else{
			entityView = locationhouseF7Judge(editData
					.getWarehouse().getId().toString());
		}
		
		try {
			LocationCollection local = LocationFactory.getRemoteInstance()
					.getLocationCollection(entityView);
			if (local.size() > 0) {
				if (com.kingdee.bos.ui.face.UIRuleUtil.isNull(editData
						.getLocationhouse())) {
					throw new com.kingdee.eas.common.EASBizException(
							com.kingdee.eas.common.EASBizException.CHECKBLANK,
							new Object[] { "库位" });

				}
			}
		} catch (BOSException e1) {
			e1.printStackTrace();
		}
	}

  e)在EDITUI构造方法中调用建立的方法事件

  

public F7FilterEditUI() throws Exception {
		super();
		initF7();
                locationhouseF7(null);
	}

 三、完成后,刷新启动服务,便可实现F7动态级联,并实现动态改必输校验。开发

 -----------------------------------------get

附加一个自定义Query小知识:只须要将须要从新绑定的Query,从新set一下就能够了。

private void initF7() {
		this.prmtwarehouse.setQueryInfo("com.kingdee.eas.demo.f7.app.warehouseUserDefine");		
     。。。。。。      
}

 PS:自定义Query的一个注意事项,不能设置id不可见,否则选择时,会提示报错。

相关文章
相关标签/搜索