NC编辑事件选中表头某个字段自动带出表体
表头表体要有关联,通过封装好的查询方法查询的
1 //获得当前编辑字段的名字 2 String key =e.getKey(); 3 BillCardPanel pane=e.getBillCardPanel(); 4 // AggQcFormbatchVO aggvo=(AggQcFormbatchVO)getModel().getSelectedData(); 5 //判断当前编辑字段是否符合要求 6 if ("pk_initialchecks".equals(key)) { 7 //查询方法 8 HYPubBO bo =new HYPubBO(); 9 try { 10 //创建表体vos将查询到的vos的长度给bvos 11 QcFormbatchBVO[] bvos=new QcFormbatchBVO[bo.queryByCondition(QcFormbatchBVO.class, "pk_initialcheck = '"+pane.getHeadItem("pk_initialchecks").getValue()+"' and nvl(dr,0)=0 and pk_formbatch is null").length]; 12 //循环表体vos的长度将查询到的数据放在bvos里面 13 for (int i = 0; i < bvos.length; i++) { 14 bvos[i]=(QcFormbatchBVO) bo.queryByCondition(QcFormbatchBVO.class, "pk_initialcheck = '"+pane.getHeadItem("pk_initialchecks").getValue()+"' and nvl(dr,0)=0 and pk_formbatch is null")[i]; 15 } 16 17 for (int i = 0; i < bvos.length; i++) { 18 //增行 19 pane.addLine(); 20 pane.getBillModel().setBodyRowVO(bvos[i], i); 21 if (i==0) { 22 pane.setBodyValueAt(10, i, pane.getBodyPanel().getBodyKeyByCol(i)); 23 }else { 24 pane.setBodyValueAt((i+1)*10, i, pane.getBodyPanel().getBodyKeyByCol(i)); 25 } 26 } 27 28 } catch (UifException e1) { 29 // TODO 自动生成的 catch 块 30 e1.printStackTrace(); 31 } 32 }