Columns¶
Overview¶
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 |
---|---|---|
1 | setTitle(String title),
setTitle(DRIExpression<?> titleExpression)
|
Sets the column title |
2 | setTitleStyle(StyleBuilder titleStyle) | Sets the column title style |
3 | 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
|
4 | setTitleHeight(Integer height),
setTitleFixedHeight(Integer height),
setTitleMinHeight(Integer height)
|
Sets the height of a column title |
Configuration options of column values
# | method | description |
---|---|---|
1 | setStyle(StyleBuilder style) | Sets the column value style |
2 | setPrintWhenExpression(DRIExpression
<Boolean> printWhenExpression)
|
must be a type of Boolean and it decides
whether or not a column value will be print
|
3 | 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
|
4 | setHeight(Integer height),
setFixedHeight(Integer height),
setMinHeight(Integer height)
|
Sets the height of a column value |
5 | setPrintRepeatedDetailValues(Boolean
printRepeatedDetailValues)
|
Specifies whether or not print a value if the
value is the same as the previous value
|
6 | setHorizontalAlignment(HorizontalAlignment
horizontalAlignment)
|
Sets the column value horizontal alignment |
7 | setPattern(String pattern),
setPattern(DRIExpression<String>
patternExpression)
|
Sets the column value format pattern |
8 | setValueFormatter(DRIValueFormatter
<?, ? super U> valueFormatter)
|
Sets the column value format expression |
9 | setHyperLink(HyperLinkBuilder hyperLink) | Sets the column value hyperlink |
a | setStretchWithOverflow(Boolean
stretchWithOverflow)
|
|
b | 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 |
---|---|---|
1 | setColumns(Integer columns),
setFixedColumns(Integer columns),
setMinColumns(Integer columns)
|
This method is used to define the width of a
a column. The width is set to the columns
multiplied by width of the character m for
the used font
|
2 | setWidth(Integer width),
setFixedWidth(Integer width),
setMinWidth(Integer width)
|
Sets the width of a column |
Text column¶
It is represented by a TextColumnBuilder instance and it is used to show values from the data source.
Builders
# | method | description |
---|---|---|
1 | 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
|
2 | 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
|
3 | 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
|
4 | 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
|
5 | 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
|
6 | 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
|
7 | columnInstance.divide(int scale,
TextColumnBuilder<? extends Number> col),
columnInstance.divide(int scale,
Number number)
|
Creates a new column by dividing the
columnInstance column with a value or a column
value
|
1 2 3 4 5 | report()
.columns(
col.column("Item", "item", type.stringType()),
col.column("Quantity", "quantity", type.integerType()))
.setDataSource(...)
|
Another example: ColumnDataTypesReport
Expression column¶
It is represented by a TextColumnBuilder instance and the displayed values are defined in an expression.
Builders
# | method | description |
---|---|---|
1 | 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
|
1 2 3 4 5 6 7 8 9 | report()
.columns(
col.column("Expression column", new ExpressionColumn()))
.setDataSource(...)
private class ExpressionColumn extends AbstractSimpleExpression<String> {
public String evaluate(ReportParameters reportParameters) {
return ...;
}
}
|
Another example: ExpressionColumnReport
Percentage column¶
It is represented by a PercentageColumnBuilder instance. It calculates percentage values from the field or column values.
Builders
# | method | description |
---|---|---|
1 | col.percentageColumn(ValueColumnBuilder<?,
? extends Number> column),
col. percentageColumn(String title,
ValueColumnBuilder<?, ? extends Number> col)
|
Creates a new percentage column from the
column values
- title (optional) - the column title
- column - the column definition
|
2 | col.percentageColumn(String field, Class<?
extends Number> valueClass),
col.percentageColumn(String fld, String s1,
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
|
3 | 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 |
---|---|---|
1 | setTotalType(PercentageTotalType totalType) | Sets the total type. Has effect only when the report contains at least one group |
2 | setTotalGroup(GroupBuilder<?> totalGroup) | Sets the total group. Has effect only when the report contains at least one group |
1 2 3 4 5 6 | TextColumnBuilder<Integer> quantityColumn = col.column("Quantity", "quantity", type.integerType());
PercentageColumnBuilder quantityPercColumn = col.percentageColumn("Quantity [%]", quantityColumn);
report()
.columns(
quantityColumn, quantityPercColumn)
.setDataSource(...)
|
Another example: PercentageColumnsReport
Row number column¶
It is represented by a TextColumnBuilder instance and displays row numbers. Builders
# | method | description |
---|---|---|
1 | col.columnRowNumberColumn(),
col.columnRowNumberColumn(String title)
|
Create a new row number column, the row number
| is reset on each new column
- title (optional) - the column title
|
2 | col.pageRowNumberColumn(),
col.pageRowNumberColumn(String title)
|
Create a new row number column, the row number
is reset on each new page
- title (optional) - the column title
|
3 | col.reportRowNumberColumn(),
col.reportRowNumberColumn(String title)
|
Creates a new row number column
- title (optional) - the column title
|
1 2 3 4 | report()
.columns(
col.reportRowNumberColumn("Report row"))
.setDataSource(...)
|
Another example: RowNumberColumnsReport
Boolean column¶
It is represented by a BooleanColumnBuilder instance and shows a boolean value either as a text or as an image.
Builders
# | method | description |
---|---|---|
1 | col.booleanColumn(String field),
col.booleanColumn(String titl, String fld)
|
Creates a new boolean column
- titl (optional) - the column title
- fld - the name of the field
|
2 | col.booleanColumn(FieldBuilder<Boolean> fld),
col.booleanColumn(String title, FieldBuilder
<Boolean> fld)
|
Creates a new boolean column
- title (optional) - the column title
| - fld - the field definition
|
3 | col.booleanColumn(DRIExpression<Boolean> ex),
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 |
---|---|---|
1 | setComponentType(BooleanComponentType
booleanComponentType)
|
Sets the boolean presentation type.
BooleanComponentType.TEXT_* - shows a text value
BooleanComponentType.IMAGE_* - shows an image
|
2 | setImageDimension(Integer we, Integer ht),
setImageWidth(Integer width),
setImageHeight(Integer height)
|
Sets the boolean image dimension. Has effect
only when the boolean value is presented as an
image
|
1 2 3 4 5 | report()
.columns(
col.booleanColumn("Boolean", "boolean"),
col.booleanColumn("Boolean", "boolean").setComponentType(BooleanComponentType.IMAGE_STYLE_1))
.setDataSource(...)
|
Another example: BooleanColumnReport
Component column¶
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 |
---|---|---|
1 | col.componentColumn(ComponentBuilder<?,
?> component),
col.componentColumn(String title,
ComponentBuilder<?, ?> component)
|
Creates a new component column
- title (optional) - the column title
- component - the component definition
|
1 2 3 4 5 6 7 | ImageBuilder image = cmp.image(...);
ComponentBuilder<?, ?> component = ...;
report()
.columns(
col.componentColumn("Image", image),
col.componentColumn("Component", component))
.setDataSource(...)
|