intive-FDV / DynamicJasper

Dynamic Reports using Jasper Reports
http://intive-fdv.github.io/DynamicJasper/
GNU Lesser General Public License v3.0
242 stars 127 forks source link

Setting value as Group Label using CustomExpression #76

Open kokhoor opened 6 years ago

kokhoor commented 6 years ago

Hi I tried to use CustomExpression for group label, to display my label for the group total using this format: "Status: Open"

Unfortunately, the label turns out blank. Is there anyway for me to troubleshoot? My parameter has empty default string, and I cannot tell how the expression: (ar.com.fdvs.dj.domain.CustomExpression)$P{REPORT_PARAMETERS_MAP}.get... is evaluating the custom expression. My snippet (modified) is below:

GroupBuilder gb = new GroupBuilder();
gb.setCriteriaColumn(groupColumn);
gb.addFooterVariable(numberColumn, DJCalculation.SUM, style);
String columnName = strColumnName;
CustomExpression ce = new CustomExpression() {
    public Object evaluate(Map fields, Map variables, Map parameters) {
        return columnName + ": " + fields.get(columnName);
    }

    public String getClassName() {
        return dataType;
    }
};
DJGroupLabel groupLabel = new DJGroupLabel(ce, style, LabelPosition.LEFT);
gb.setFooterLabel(groupLabel);