在Primefaces Organigram中,似乎它不遵循列出节点的实际排序。例如,我总共有4个节点,表示如下:
我所期待的是Organigram将如下列出:
但它反而列出了这个:
我弄清楚它总是将叶节点(没有子节点)移到左边。如果我从列表中删除节点4,它将恢复正常排序,即左侧的节点2和右侧的节点3。有没有想法克服这个问题?
这是我的支持bean:
private AccountModel user;
private OrganigramNode root;
public void onLoad()
{
user = accountService.findOne(SystemUtils.getCurrentUser().getId());
if (user.getUpline() == null)
root = new DefaultOrganigramNode("root", user, null);
else
root = new DefaultOrganigramNode("root", user.getUpline(), null);
List<AccountModel> downlines = ((AccountModel) root.getData()).getDownline();
for (AccountModel downline : downlines)
{
addDownline(root, downline);
}
}
public void addDownline(OrganigramNode parent, AccountModel target)
{
String type = "downline";
if (target.getUsername().equals(user.getUsername()))
type = "user";
OrganigramNode child = new DefaultOrganigramNode(type, target, parent);
if (!target.getDownline().isEmpty())
{
for (AccountModel downline : target.getDownline())
{
addDownline(child, downline);
}
}
}
这是我的页面:
<p:organigram id="network" widgetVar="network"
value="#{networkBean.root}" var="node">
<p:organigramNode type="root">
<p:outputLabel value="#{node.data.profile.fullName}" />
</p:organigramNode>
<p:organigramNode type="user" icon="ui-icon-person">
<p:outputLabel value="#{node.data.profile.fullName}" />
</p:organigramNode>
<p:organigramNode type="downline">
<p:outputLabel value="#{node.data.profile.fullName}" />
</p:organigramNode>
</p:organigram>