Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 伯特。在动态组的组页眉/页脚中显示当前分组值_Java_Report_Birt - Fatal编程技术网

Java 伯特。在动态组的组页眉/页脚中显示当前分组值

Java 伯特。在动态组的组页眉/页脚中显示当前分组值,java,report,birt,Java,Report,Birt,简短问题: 我有一个可以在运行时更改分组条件的组(请参阅下面长问题中的详细信息)。我是否可以在组页眉/页脚中显示组的当前值(例如,按分行分组-显示分行名称、按客户分组-客户名称等) 长问题: 我希望允许我的用户动态更改分组条件。我可以通过两种方式相对容易地实现这一点: 通过BIRT设计时API(传递给组相应的行/数据集列值) 通过报告参数。将数据集列名作为参数值传递,并在组条件中像 eval(参数[“groupColumnName”].value) 我的问题是,我必须在组标题中显示当前组的值(在

简短问题:

我有一个可以在运行时更改分组条件的组(请参阅下面长问题中的详细信息)。我是否可以在组页眉/页脚中显示组的当前值(例如,按分行分组-显示分行名称、按客户分组-客户名称等)

长问题:

我希望允许我的用户动态更改分组条件。我可以通过两种方式相对容易地实现这一点:

  • 通过BIRT设计时API(传递给组相应的行/数据集列值)
  • 通过报告参数。将数据集列名作为参数值传递,并在组条件中像

    eval(参数[“groupColumnName”].value)

  • 我的问题是,我必须在组标题中显示当前组的值(在组页脚中也可以重复该值)

    我不知道如何实现选项1。(设计时API)

    选择2。我可以重复2中的Java脚本。在组页眉/页脚中,但这不是我想要实现的。我不想重复那个繁琐的java脚本2-3次。我是否可以在组级别定义该值(类似于组的命名查询),然后在组条件、页眉和页脚中重用它

    可能的BIRT允许按组名显示分组的当前值


    欢迎任何想法。

    您可以通过以下两种方式之一实现选项2:

  • 将计算列添加到数据集中,并使用计算参数的公式,然后根据报告中的要求对计算列进行分组/包括
  • 如果您使用的是SQL数据源,请在参数值。。。并根据报告中的要求分组/包括新字段

  • 我所做的-通过DataItem和TextItem的API更改组页眉/页脚

    以防万一,如果有人现在想了解我的解决方法:

        private static void processRowHandle(SlotHandle pSlotHandle, ReportGroup pGroupInfo) throws SemanticException {
        if (pSlotHandle == null) return;
        for(Object obj : pSlotHandle.getContents()){
            if (obj instanceof RowHandle){
                SlotHandle cells = ((RowHandle)obj).getCells();
                if (cells == null) continue;
                for(Object item : cells.getContents()){
                    if (item instanceof CellHandle){
                        SlotHandle content = ((CellHandle)item).getContent();
                        if (content == null) continue;
                        for(Object cell : content.getContents()){
                            if (cell instanceof DesignElementHandle) processGroupLabels((DesignElementHandle) cell, pGroupInfo);
                        }
                    }
                }
            }
        }
    }
    
    private static void processGroupLabels(DesignElementHandle pElementHandle, ReportGroup pGroupInfo) throws SemanticException {
        if (pElementHandle instanceof DataItemHandle){
            DataItemHandle dataItemHandle = (DataItemHandle)pElementHandle;
            if (pGroupInfo.getOldBindingName().equals(dataItemHandle.getResultSetColumn())){
                dataItemHandle.setResultSetColumn(pGroupInfo.getNewColumn().getBindingNameText());
            }
        }
        if (pElementHandle instanceof TextItemHandle){
            String newColumnBindingText = ExpressionUtil.createRowExpression(pGroupInfo.getNewColumn().getBindingNameText());
            String content = ((TextItemHandle)pElementHandle).getContent().replace(pGroupInfo.getOriginalExpression(), newColumnBindingText);
            ((TextItemHandle)pElementHandle).setContent(content);
        }
    }