You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调整Nattable树层级显示顺序:优先展示子模块

Nattable树结构自定义显示顺序实现

需求说明

当前Nattable树结构的层级关系如下:

  • 第36、37行是第20行的子模块
  • 第21、23至34行是第20行的子节点
  • 第22行是第21行的子节点(即第20行的孙节点)

需要调整第20行子节点的显示顺序,让第36、37行优先显示,替代当前第21行的位置。

当前实现代码

目前使用TreeList渲染Nattable数据,相关Java代码如下:

private List<ISectionInfo> getFlatList(List<ISectionInfo> inputList)
{
    List<ISectionInfo> flatList = new ArrayList<ISectionInfo>();

    for (ISectionInfo node : inputList)
    {

        if (node instanceof SectionInfo) 
        {
            SectionInfo secNode = (SectionInfo) node;

            if (!hasChildren(secNode))
            {
                flatList.add(secNode);
                flatList.addAll(secNode.getModuleInfoList());

            }
            if (hasChildren(secNode))
            {
                flatList.addAll(secNode.getModuleInfoList());
                flatList.add(secNode);

                for (ISectionInfo iternode : secNode.getChildren())
                {
                    flatList.addAll(((SectionInfo) iternode).getModuleInfoList());
                    flatList.add(iternode);

                }

            }
        }

    }

    return flatList;

}

内容的提问来源于stack exchange,提问作者Sridhar Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 01:45:43