EAS中对KDTable单元格使用快捷键触发值改变事件
// 设置拷贝模式:只拷贝单元格的值
this.kdtProduct.getEditHelper().setCoypMode(KDTEditHelper.VALUE);
//注册事件
kdtProduct.addBeforeActionListener(new BeforeActionListener() {
public void beforeAction(BeforeActionEvent e) {
try {
kdtProduct_beforePropertyChange(e);
} catch (Exception e1) {
handUIException(e1);
}
}
});
kdtProduct.addAfterActionListener(new BeforeActionListener() {
public void beforeAction(BeforeActionEvent e) {
try {
kdtProduct_afterPropertyChange(e);
} catch (Exception e1) {
handUIException(e1);
}
}
});
//新旧值处理
// 使用快捷键之前,缓存旧值
BigDecimal oldAmount = SysConstant.BIGZERO;
BigDecimal newAmount = SysConstant.BIGZERO;
// 使用Copy、cut快捷键时,将当前单元格的值缓存为新值,delete时,为旧值
private void kdtProduct_beforePropertyChange(BeforeActionEvent e) throws Exception{
int evtType = e.getType();
KDTSelectManager kdtSelMgr = kdtProduct.getSelectManager();
int rowIndex = kdtSelMgr.getActiveRowIndex();
int colIndex = kdtSelMgr.getActiveColumnIndex();
if (colIndex == kdtProduct.getColumnIndex("amount")) {
Object obj = kdtProduct.getCell(rowIndex, colIndex).getValue();
if (evtType == BeforeActionEvent.ACTION_COPY ||
evtType ==BeforeActionEvent.ACTION_CUT) {
newAmount = obj == null ? null : new BigDecimal(obj.toString());
} else if (evtType == BeforeActionEvent.ACTION_DELETE){
oldAmount = obj == null ? null : new BigDecimal(obj.toString());
}
} else {
newAmount = null;
}
}
// 快捷键使用后处理
private void kdtProduct_afterPropertyChange(BeforeActionEvent e) throws Exception {
int evtType = e.getType();
KDTSelectManager kdtSelMgr = kdtProduct.getSelectManager();
int rowIndex = kdtSelMgr.getActiveRowIndex();
int colIndex = kdtSelMgr.getActiveColumnIndex();
if (colIndex == kdtProduct.getColumnIndex("amount")) {
if (evtType == BeforeActionEvent.ACTION_PASTE ||
evtType == BeforeActionEvent.ACTION_DELETE) {
if (evtType == BeforeActionEvent.ACTION_PASTE) {
Object obj = kdtProduct.getCell(rowIndex, colIndex).getValue();
oldAmount = obj == null ? null : new BigDecimal(obj.toString());
} else {
newAmount = null;
}
// 业务处理
}
}
oldAmount = null;
}
EAS中对KDTable单元格使用快捷键触发值改变事件
本文2024-09-16 22:09:12发表“eas cloud知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-eas-46261.html