Footer for index column (RowHeaderMode.INDEX), possible?

Hello,

I have a table with an extra column showing indexes:

table.setRowHeaderMode(RowHeaderMode.INDEX); Can I add a footer under the index column, showing the total row count?

I tried:

int rowCount = resultsList.size(); //my row count
table.setColumnFooter(null, String.valueOf(rowCount));

but it doesn’t work (no number is shown). Any ideas?

Kind regards,

Jim

Hello Jim,
you can try it by doing something like this:

int number=table.getContainerDataSource().size(); //getContainerDataSourse() returns the viewing data-source container. //.size() returns the number of visible items in the container; in your case - rows //then ou can try by adding footer as you have done before: table.setColumnFooter(null,String.valueOf(number)) Hopefully it will help : )

Anastasia hi,

Thanks for replying. The problem is that tha last line table.setColumnFooter(null,String.valueOf(number)) is not doing anything under the index column.

I think that the property corresponding to the index column is not “null”

Regards,

Jim

Hello Jim,
you are right, it just can’t work:
It should be something like this:

[code]
// Have a table with a numeric column
Table table = new Table(“Custom Table Footer”);
table.addContainerProperty(“Name”, String.class, null);
table.addContainerProperty(“Died At Age”, Integer.class, null);

// Set the footers
table.setFooterVisible(true);
table.setColumnFooter(“Name”, “Average”);
table.setColumnFooter(“Died At Age”, String.valueOf(avgAge))
[/code]So you have to specify column explicitly (by name, for example) as you have mentioned.
Here is the full example of setColumnFooter usage:
https://vaadin.com/docs/-/part/framework/components/components-table.html