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