Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Showing boolean values with checkbox in a non-editable table

Fredrik Ferm
1 decade ago Feb 02, 2011 9:16am
Charles Anthony
1 decade ago Feb 02, 2011 2:27pm
Marko Grönroos
1 decade ago Feb 02, 2011 3:11pm
Anders Andersen
1 decade ago Jul 15, 2011 1:48pm
Denis Vulinovich
1 decade ago Sep 05, 2012 4:58am
Henrik Refsnes
10 years ago Dec 12, 2012 7:58pm
HARSH DOSHI
9 years ago Jun 23, 2013 9:15pm
Stefan Endrullis
9 years ago Nov 04, 2013 5:16pm

Another solution is to use checkbox characters, such as ☒, ☑, and ☐, or simple tick characters ✓ or ✔.  Then you can use formatPropertyValue again:

@Override
    protected String formatPropertyValue(Object rowId, Object colId, Property property) {
        if (property.getType() == Boolean.class) {
            if (property.getValue() == null) {
                return "";
            } else
            if ((Boolean) property.getValue()) {
                return "☒";
            } else {
                return "☐";
            }
        } else {
            return super.formatPropertyValue(rowId, colId, property);
        }
    }
Joao Nicolau
8 years ago Jul 08, 2014 10:34am

This solution works for me: (with checkbox characters, such as ☒, ☑, and ☐ from previous post)

table.setConverter("column_name", new StringToBooleanConverter() {
   @Override
   protected String getTrueString() {
      return "☒";
   }
   @Override
   protected String getFalseString() {
      return "☐";
   }
});
Marko Grönroos
8 years ago Jul 08, 2014 3:47pm