DynamicReports has an ability to display data in a multi-column layout. There is no limit in number of columns added to the report, only keep in mind that the more columns you add to the report, the less space will be available for each column.
All columns automatically fit the available page width.
The picture above shows what is a column and how it is divided.
Configuration options of a column title
method | description |
---|---|
setTitle(String title), setTitle(DRIExpression<?> titleExpression) |
Sets the column title |
setTitleStyle(StyleBuilder titleStyle) | Sets the column title style |
setTitleRows(Integer rows), setTitleFixedRows(Integer rows), setTitleMinRows(Integer rows) |
This method is used to define the height of a column title. The height is set to the rows multiplied by height of the font |
setTitleHeight(Integer height), setTitleFixedHeight(Integer height), setTitleMinHeight(Integer height) |
Sets the height of a column title |
Configuration options of column values
method | description |
---|---|
setStyle(StyleBuilder style) | Sets the column value style |
setPrintWhenExpression(DRIExpression<Boolean> printWhenExpression) | Sets the print when expression. The expression must be a type of Boolean and it decides whether or not a column value will be printed |
setRows(Integer rows), setFixedRows(Integer rows), setMinRows(Integer rows) |
This method is used to define the height of a column value. The height is set to the rows multiplied by height of the font |
setHeight(Integer height), setFixedHeight(Integer height), setMinHeight(Integer height) |
Sets the height of a column value |
setPrintRepeatedDetailValues(Boolean printRepeatedDetailValues) | Specifies whether or not print a value if the value is the same as the previous value |
setHorizontalAlignment(HorizontalAlignment horizontalAlignment) | Sets the column value horizontal alignment |
setPattern(String pattern), setPattern(DRIExpression<String> patternExpression) |
Sets the column value format pattern |
setValueFormatter(DRIValueFormatter<?, ? super U> valueFormatter) | Sets the column value format expression |
setHyperLink(HyperLinkBuilder hyperLink) | Sets the column value hyperlink |
setStretchWithOverflow(Boolean stretchWithOverflow) | |
addProperty(DRIPropertyExpression propertyExpression), addProperty(String name, DRIExpression<String> valueExpression), addProperty(String name, String value) |
Adds a jasper property to the column value |
Configuration options of a column
method | description |
---|---|
setColumns(Integer columns), setFixedColumns(Integer columns), setMinColumns(Integer columns) |
This method is used to define the width of a column. The width is set to the columns multiplied by width of the character m for the used font |
setWidth(Integer width), setFixedWidth(Integer width), setMinWidth(Integer width) |
Sets the width of a column |
Examples
Column examples
It is represented by a TextColumnBuilder instance and it is used to show values from the data source.
Builders
method | description |
---|---|
col.column(String fieldName, Class<T> valueClass), col.column(String title, String fieldName, Class<T> valueClass) |
Creates a new column - title (optional) - the column title - fieldName - the name of the field - valueClass - the field value class |
col.column(String fieldName, DRIDataType<? super T, T> dataType), col.column(String title, String fieldName, DRIDataType<? super T, T> dataType) |
Creates a new column - title (optional) - the column title - fieldName - the name of the field - dataType - the field data type |
col.column(FieldBuilder<T> field), col.column(String title, FieldBuilder<T> field) |
Creates a new column - title (optional) - the column title - field - the field definition |
columnInstance.add(TextColumnBuilder<? extends Number> column), columnInstance.add(Number number) |
Creates a new column by adding a value or a column value to the columnInstance column |
columnInstance.subtract(TextColumnBuilder<? extends Number> column), columnInstance.subtract(Number number) |
Creates a new column by subtracting a value or a column value from the columnInstance column |
columnInstance.multiply(TextColumnBuilder<? extends Number> column), columnInstance.multiply(Number number) |
Creates a new column by multiplying the columnInstance column with a value or a column value |
columnInstance.divide(int scale, TextColumnBuilder<? extends Number> column), columnInstance.divide(int scale, Number number) |
Creates a new column by dividing the columnInstance column with a value or a column value |
Examples
Quick usage:
report() .columns( col.column("Item", "item", type.stringType()), col.column("Quantity", "quantity", type.integerType())) .setDataSource(...)Another example: ColumnDataTypesReport
It is represented by a TextColumnBuilder instance and the displayed values are defined in an expression.
Builders
method | description |
---|---|
col.column(DRIExpression<T> expression), col.column(String title, DRIExpression<T> expression) |
Creates a new expression column - title (optional) - the column title - expression - the value expression |
Examples
Quick usage:
report() .columns( col.column("Expression column", new ExpressionColumn())) .setDataSource(...) private class ExpressionColumn extends AbstractSimpleExpression<String> { public String evaluate(ReportParameters reportParameters) { return ...; } }Another example: ExpressionColumnReport
It is represented by a PercentageColumnBuilder instance. It calculates percentage values from the field or column values.
Builders
method | description |
---|---|
col.percentageColumn(ValueColumnBuilder<?, ? extends Number> column), col. percentageColumn(String title, ValueColumnBuilder<?, ? extends Number> column) |
Creates a new percentage column from the column values - title (optional) - the column title - column - the column definition |
col.percentageColumn(String fieldName, Class<? extends Number> valueClass), col.percentageColumn(String title, String fieldName, Class<? extends Number> valueClass) |
Creates a new percentage column from the field values - title (optional) - the column title - fieldName - the name of the field - valueClass - the field value class |
col.percentageColumn(FieldBuilder<? extends Number> field), col.percentageColumn(String title, FieldBuilder<? extends Number> field) |
Creates a new percentage column from the field values - title (optional) - the column title - field - the field definition |
Configuration options
method | description |
---|---|
setTotalType(PercentageTotalType totalType) | Sets the total type. Has effect only when the report contains at least one group |
setTotalGroup(GroupBuilder<?> totalGroup) | Sets the total group. Has effect only when the report contains at least one group |
Examples
Quick usage:
TextColumnBuilder<Integer> quantityColumn = col.column("Quantity", "quantity", type.integerType()); PercentageColumnBuilder quantityPercColumn = col.percentageColumn("Quantity [%]", quantityColumn); report() .columns( quantityColumn, quantityPercColumn) .setDataSource(...)Another example: PercentageColumnsReport
It is represented by a TextColumnBuilder instance and displays row numbers.
Builders
method | description |
---|---|
col.columnRowNumberColumn(), col.columnRowNumberColumn(String title) |
Creates a new row number column, the row number is reset on each new column - title (optional) - the column title |
col.pageRowNumberColumn(), col.pageRowNumberColumn(String title) |
Creates a new row number column, the row number is reset on each new page - title (optional) - the column title |
col.reportRowNumberColumn(), col.reportRowNumberColumn(String title) |
Creates a new row number column - title (optional) - the column title |
Examples
Quick usage:
report() .columns( col.reportRowNumberColumn("Report row")) .setDataSource(...)Another example: RowNumberColumnsReport
It is represented by a BooleanColumnBuilder instance and shows a boolean value either as a text or as an image.
Builders
method | description |
---|---|
col.booleanColumn(String fieldName), col.booleanColumn(String title, String fieldName) |
Creates a new boolean column - title (optional) - the column title - fieldName - the name of the field |
col.booleanColumn(FieldBuilder<Boolean> field), col.booleanColumn(String title, FieldBuilder<Boolean> field) |
Creates a new boolean column - title (optional) - the column title - field - the field definition |
col.booleanColumn(DRIExpression<Boolean> expression), col.booleanColumn(String title, DRIExpression<Boolean> expression) |
Creates a new boolean column - title (optional) - the column title - expression - the boolean value expression |
Configuration options
method | description |
---|---|
setComponentType(BooleanComponentType booleanComponentType) | Sets the boolean presentation type. BooleanComponentType.TEXT_* - shows a text value BooleanComponentType.IMAGE_* - shows an image |
setImageDimension(Integer width, Integer height), setImageWidth(Integer width), setImageHeight(Integer height) |
Sets the boolean image dimension. Has effect only when the boolean value is presented as an image |
Examples
Quick usage:
report() .columns( col.booleanColumn("Boolean", "boolean"), col.booleanColumn("Boolean", "boolean").setComponentType(BooleanComponentType.IMAGE_STYLE_1)) .setDataSource(...)Another example: BooleanColumnReport
It is represented by a ComponentColumnBuilder instance and is used to display custom components (e.g. images or complex content) in columns.
Builders
method | description |
---|---|
col.componentColumn(ComponentBuilder<?, ?> component), col.componentColumn(String title, ComponentBuilder<?, ?> component) |
Creates a new component column - title (optional) - the column title - component - the component definition |
Examples
Quick usage:
ImageBuilder image = cmp.image(...); ComponentBuilder<?, ?> component = ...; report() .columns( col.componentColumn("Image", image), col.componentColumn("Component", component)) .setDataSource(...)Another example: ComponentColumnReport