Class DataTablesColumns
columns
array from the bean properties of a row type, so the browser-side column list doesn't have to be hand-duplicated.
Each generated column descriptor carries the four fields DataTables reads for a server-side-processing column:
data — the bean property name (also the JSON key DataTables reads from each row).title — the human-readable header. Sourced from@Schema(title)on the property (field or getter) when present, otherwise a humanized form of the property name (e.g."releaseDate"→"Release Date").orderable /searchable — both default totrue (DataTables' own defaults), emitted explicitly so the array is self-describing.
Columns are emitted in Juneau bean-property order (the same order the negotiated serializer uses for the row data),
so a generated columns array lines up positionally with the data rows in a
DataTablesResults envelope.
Example:
The result is an ordinary List<Map<String,Object>>; serialize it with any Juneau serializer (or embed it in a
page) to produce the JSON DataTables' columns option expects.
See Also:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionGenerates the DataTablescolumnsarray for the specified bean type using the default marshalling context.of(MarshallingContext ctx, Class<?> beanClass) Generates the DataTablescolumnsarray for the specified bean type using the specified marshalling context.
-
Method Details
-
of
Generates the DataTablescolumnsarray for the specified bean type using the default marshalling context.- Parameters:
beanClass- The row bean type. Must not benull and must be a bean.- Returns:
- A new mutable list of column descriptors, in bean-property order.
- Throws:
IllegalArgumentException- If the class is not a bean (no readable bean properties could be resolved).
-
of
Generates the DataTablescolumnsarray for the specified bean type using the specified marshalling context.- Parameters:
ctx- The marshalling context supplying the bean metadata (e.g. property naming/ordering). Must not benull .beanClass- The row bean type. Must not benull and must be a bean.- Returns:
- A new mutable list of column descriptors, in bean-property order.
- Throws:
IllegalArgumentException- If the class is not a bean (no readable bean properties could be resolved).
-