此文章只适用于单据查看,不适用对单据的更新操作
需求:
A单是源单,下推目标单 B,目标单B进行填写数量,然后保存。现在B单据不在更新,由于单据体分录太多,用户想在看的时候不显示数量为0的行
方式一:删除不需要的行,关闭页面会触发修改校验
IDataModel model = this.getModel();
DynamicObjectCollection kdec_entryentity = model.getEntryEntity("kdec_entryentity");
int [] deleteIndex = null;
for (int i = kdec_entryentity.size() - 1; i >= 0; i--) {
DynamicObject dynamicObject = kdec_entryentity.get(i);
int kdec_qtyfield = dynamicObject.getInt("kdec_qtyfield");
if(kdec_qtyfield == 0){
model.deleteEntryRow("kdec_entryentity",i);
}
}
//取消数据修改校验
@Override
public void beforeClosed(BeforeClosedEvent e) {
super.beforeClosed(e);
e.setCheckDataChange(false);
}
方式二:把需要展示的行赋值给单据体控件,不会触发修改校验
DynamicObjectCollection kdec_entryentity = this.getModel().getEntryEntity("kdec_entryentity");
DynamicObjectCollection clone = new DynamicObjectCollection();
for (DynamicObject dynamicObject : kdec_entryentity) {
int kdec_qtyfield = dynamicObject.getInt("kdec_qtyfield");
if(kdec_qtyfield > 0){
clone.add(dynamicObject);
}
}
this.getModel().setValue("kdec_entryentity",clone);
参考文档:https://vip.kingdee.com/article/228922061182734592
推荐阅读