////////////////////
protected void tblMain_tableClicked(com.kingdee.bos.ctrl.kdf.table.event.KDTMouseEvent e) throws Exception
{super.tblMain_tableClicked(e);
int index = e.getRowIndex();
int colIndex = e.getColIndex();
if(colIndex == tblMain.getColumnIndex("number") || e.getClickCount()==1){
Object object = tblMain.getCell(index, colIndex).getValue();
if(object instanceof CellTreeNode){
CellTreeNode node = (CellTreeNode) object;
node.doTreeClick(tblMain,tblMain.getCell(index, colIndex));
}
}
}
///////////////////////
private CellTreeNode createCellTreeNode(String name,int level,boolean isLeaf){
CellTreeNode node = new CellTreeNode();
node.setTreeLevel(level);
node.setValue(name);
node.setCollapse(false);
node.setHasChildren(!isLeaf);
return node;
}
///////////////////////////
public void onLoad() throws Exception {
DataSynchronismFacadeFactory.getRemoteInstance().deleteUnUnit();
super.onLoad();
tblMain.getDataRequestManager().setDataRequestMode(KDTDataRequestManager.REAL_MODE);
// DataSynchronismFacadeFactory.getRemoteInstance().DataSynchronism();
btnAddNew.setVisible(false);
tblMain.addKDTDataFillListener(new KDTDataFillListener(){
public void afterDataFill(KDTDataRequestEvent arg0) {
int rowIndex = tblMain.getRowCount();
for(int i=rowIndex-1;i>=0;i--){
if(!isNeed(UIRuleUtil.getString(tblMain.getCell(i,"number").getValue()))){
tblMain.removeRow(i);
continue;
}
int level = UIRuleUtil.getIntValue(tblMain.getCell(i,"level").getValue());
boolean isLeaf = UIRuleUtil.getBooleanValue(tblMain.getCell(i,"isLeaf").getValue());
String name = tblMain.getCell(i,"promAdminUnit.name").getValue().toString();
CellTreeNode cellTreeNode = createCellTreeNode(name.trim(), level, isLeaf);
tblMain.getCell(i, "promAdminUnit.name").setValue(cellTreeNode);
}
}
});
tblMain.getStyleAttributes().setHorizontalAlign(HorizontalAlignment.LEFT);
}
本文介绍了如何在EAS中创建表格树结构,通过`createCellTreeNode`方法构建节点,并在`onLoad`事件中填充数据,根据数据动态调整表格内容,实现表格行的增删,以及节点的展开与折叠状态设置。
759

被折叠的 条评论
为什么被折叠?



