count items in a column vaadin

93 Views Asked by At

Good day everyone!

How do I get the number of items that a column contains? I want to hide the "Workgroup" column if it's empty, I just don't know how.

            Table tblTeachings = new Table();
            tblTeachings.addContainerProperty("#", Integer.class,0);
            tblTeachings.addContainerProperty("Course",String.class,"");
            tblTeachings.addContainerProperty("Teaching name",String.class,"");
            tblTeachings.addContainerProperty("Start date",String.class,"");
            tblTeachings.addContainerProperty("End Date",String.class,"");
            tblTeachings.addContainerProperty("Activity status",String.class,"");
            tblTeachings.addContainerProperty("Participated",String.class,"");
            tblTeachings.addContainerProperty("Workgroup",String.class,"");
            tblTeachings.setSizeFull();

            if(/*I don't know what condition should I put here*/){
                //hide the emptycolumn
            } 

Thanks!

1

There are 1 best solutions below

1
On BEST ANSWER

Columns don't contain items, Rows contain items.

You can set the visible columns by passing a array to the setVisibleColumns methos of the Table.

It could also be a idea, to just colapse the column, not hiding it...

Determining if all values of this colum are empty should be simple enogh for you. If not, then please tell us what datasource you use.