gwtgwt2gwt-2.4

GWT - datagrid column with integer values


I want to add a column to the datagrid in GWT, the column should show integer values. However, i cannot find any cell that can show an integer. This is my code

    Column<Trade, Integer> sellQuantityColumn = 
            new Column<Trade, Integer>(new NumberCell(NumberFormat.getFormat("##"))) {
                @Override
                public Integer getValue(Trade object) {
                    return object.getSellQty();
                }
            };

This shows an error - The constructor Column(NumberCell) is undefined.

For now, i can show this integer as a string, but is there any way of displaying integer values?


Solution

  • Found the answer myself,

    The correct way of using the NumberCell is to use java.lang.Number as the data type and not integer or float.

            Column<Trade, Number> sellQuantityColumn = new Column<Trade, Number>(new NumberCell()) {
                @Override
                public Integer getValue(Trade object) {
                    return object.getSellQty();
                }
            };