Group generated Columns in GroupTable

How can I group generated columns in Grouptable?

I have this example but it don’t work. It shows as a regular column but is not capable of grouping

certificatesGroupTable.addGeneratedColumn(“year”, new GroupTable.ColumnGenerator(){

        public Component generateCell(Certificate entity) {
            Label label = componentsFactory.createComponent(Label.class);
            Calendar cal = Calendar.getInstance();
            return label;
1 Like

You can’t group a table by a column which is not connected to the entity field.
If you want to group your entities by the creation date, you should use the existing field ‘createTs’. For example, if you want to group entities by the creation year, you should add a column “year” to your table in the XML file.

<column id="year"/>

Then you should write down the following code in the entity class:

private LocalDate asLocalDate(Date date) {
        return date instanceof java.sql.Date ? ((java.sql.Date) date).toLocalDate()
                : date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

    public String getYear() {
        LocalDate localDate = asLocalDate(getCreateTs());
        return String.format("%d",localDate.getYear());
1 Like

Ah. That solved the problem.

Is it possible to force the group to be expanded rater than collapsed by default?

Do you have an example of how to aggregate column values in a group table, if possible?

Could you, please, create a new topic for each of your questions? It would be helpful to other users with the same questions.