Grid, override boolean captions

Hi,

I don’t know how to do, i’ve a grid filled with a containerdatasource which contains a boolean. It results to a row with values “true” and “false” when editor isn’t enabled, I want to change these captions.

Anyone have an idea?

Thanks

You have couple of alternatives.

If you just want to show “true” or “false” as some other textual value that can be represented as a String, you could just use Converter, i.e. BooleanToString type converter, which does conversion to string you want.

If you want special effects. The next step is to use that BooleanToString type converter to create HTML snipet as a value. Then you can add standard HTMLRenderer to that column to display that HTML. This way you can for example quite easily use icons from Font Awesome or Vaadin Font Icons collections.

Ok thanks, it works

        getGrid().getColumn(BeanP.DATA_VISIBLE).setConverter(new StringToBooleanConverter(Constantes.OUI, Constantes.NON));
        final CheckBox visible = new CheckBox(Constantes.NON); // Fixes false default caption
        
        visible.addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                if(visible.getValue().equals(Boolean.TRUE)){
                    visible.setCaption(Constantes.OUI);
                } else {
                    visible.setCaption(Constantes.NON);
                }
            }
        });

        visible.setImmediate(true);
        getGrid().getColumn(BeanP.DATA_VISIBLE).setEditorField(visible);

22534.png