How can i suppress all zero value from grid's cells

hi to all
i have this problem when i display my grid

        //this solution display obviously all the zero values on the grid
        grid.addColumn(Tax::getDoubleValue, new NumberRenderer()).setId("tax").setCaption("Tax")
                .setEditorBinding(
                        binder.forField(new TextField()).withConverter(new StringToDoubleConverter("not a double!"))
                                .bind(Tax::getDoubleValue, Tax::setDoubleValue));
        //the second one solution produce follow error:

            grid.addColumn(taxList -> (taxList.getDoubleValue() == 0) ? "" :taxList.getDoubleValue(), new NumberRenderer()).setId("tax").setCaption("Tax")
                .setEditorBinding(
                        binder.forField(new TextField()).withConverter(new StringToDoubleConverter("not a double!"))
                                .bind(Tax::getDoubleValue, Tax::setDoubleValue));

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number      

can anyone help me? Thanks.

I like to override NumberRenderer to get all the behaviours specified. This example takes care of nulls, zeros (after roundind the double so as not to get a .000001…), and formats the double to one decimal place. I put these custom renderers in a GridHelper class and call them from Grids as required. Not sure it’s the best approach, but it works for me. I’ve used these since V7 and am not sure that the null protections are still required. they were at that time.

@SuppressWarnings("serial")
public class OneFirmDecimalNumberRenderer extends NumberRenderer {
    public TemporaryOneFirmDecimalNumberRenderer() { }
    @Override
    public JsonValue encode(Number value) {    
        return encode(value == null ? "" : Math.round(value.doubleValue() * 100 ) == 0 ? "" : oneFirm.format(value), String.class);
    }
}

In this case, the “oneFirm” format is specified for the whole helper class

private DecimalFormat oneFirm = new DecimalFormat("#.0");