在XML文件事件监听的bean中添加数据勾选事件,同时实现:如果勾选了一条数据,通过勾选数据行中的单据号查找整个列表界面的数据,如果有数据行的单据号跟我选择的那行数据的单据号相同的话,那相同的那行数据也一起设置勾选状态(如果是取消勾选,则同样取消勾选单据号相同的行数据)。
<!-- 事件监听newadd -->
<bean id="bmModelEventMediator" class="nc.ui.pubapp.uif2app.model.AppEventHandlerMediator">
<property name="model" ref="bmModel" />
<property name="handlerGroup">
<list>
<!-- nc.ui.pubapp.uif2app.event.OrgChangedEvent -->
<bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup">
<property name="event" value="nc.ui.pubapp.uif2app.event.OrgChangedEvent" />
<property name="handler">
<bean class="nc.ui.cmp.cmp_paymes.ace.handler.AceOrgChangeHandler" >
<property name="billForm" ref="billForm" />
</bean>
</property>
</bean>
<!-- nc.ui.pubapp.uif2app.event.billform.AddEvent -->
<bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup">
<property name="event" value="nc.ui.pubapp.uif2app.event.billform.AddEvent" />
<property name="handler">
<bean class="nc.ui.cmp.cmp_paymes.ace.handler.AceAddHandler" />
</property>
</bean>
<!-- 数据行勾选事件 -->
<bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup">
<property name="event" value="nc.ui.pubapp.uif2app.event.list.ListHeadRowStateChangeEvent" />
<property name="handler">
<bean class="nc.ui.cmp.cmp_paymes.ace.handler.AceListHeadRowStateChangeHandler" />
</property>
</bean>
</list>
</property>
</bean>
新增事件的实现类,上面xml中handler
属性设置的那个nc.ui.cmp.cmp_paymes.ace.handler.AceListHeadRowStateChangeHandler
package nc.ui.cmp.cmp_paymes.ace.handler;
import nc.ui.pubapp.uif2app.event.IAppEventHandler;
import nc.ui.pubapp.uif2app.event.list.ListHeadRowStateChangeEvent;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
/**
* 数据行勾选事件 </p>
* 创建时间: 2020年9月25日 上午11:38:43
* @author xuzihui
*
*/
public class AceListHeadRowStateChangeHandler implements IAppEventHandler<ListHeadRowStateChangeEvent> {
@Override
public void handleAppEvent(ListHeadRowStateChangeEvent e) {
//获取选中行的单据编码
Object vbillcode = e.getBillListPanel().getHeadBillModel().getValueAt(e.getRow(), "vbillcode");
if(vbillcode == null) {
ExceptionUtils.wrappBusinessException("当前行数据中单据编码为空!");
}
//获取当前查询出来的数据行数
int rowCount = e.getBillListPanel().getBillListData().getHeadBillModel().getRowCount();
for(int i = 0 ; i < rowCount ; i++){
if(i == e.getRow()) continue;
String billno = (String) e.getBillListPanel().getHeadBillModel().getValueAt(i, "vbillcode");
//如果有其它单据行的单据编码与当前选中行的单据编码相同,则同样勾选该行数据
if(vbillcode.equals(billno)){
e.getBillListPanel().getHeadBillModel().setRowState(i, e.getRowStaus());
}
}
}
}