4

Does anybody know how to achieve this?

I want to add a NumberCell to a GWT CellTable and want to use inline editing as with EditTextCell.

For a EditTextCell I use:

    Column<Parameter, String> editableColumn = new Column<Parameter, String>(
            new EditTextCell()) {
        @Override
        public String getValue(Parameter parameter) {
            return parameter.getString();
        }
    };

I want to use an "editable NumberCell", but don't have a clue how to do this.

HELP me please! :)

For a NumberCell:

    Column<Parameter, Number> column = new Column<Parameter, Number>(
            new NumberCell()) {
        @Override
        public Number getValue(Parameter parameter) {
            return (Number) parameter.getNumberValue();
        }
    };
Chris
  • 1,119
  • 1
  • 8
  • 26
  • A bit nasty, but I've taken the EditTextCell and changed my object modell to have transfer objects which are shown on the client with a "String doubleVal" which gets converted on the server to a Double. Some straightforward typing work, but I don't have to implement my own widgets... – Chris Aug 25 '11 at 13:36

1 Answers1

2

There isn't a editable cell for numbers in GWT. You could copy paste the EditTextCell and change it to use numbers instead of Strings. Plus you have to check on every keydown if the pressed key was a number key.

Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297
  • Doing as you said leads me to: Column editableColumn = new Column( new EditTextCell()) { @Override public Number getValue(Parameter parameter) { return parameter.getNumber(); } }; "The constructor Column(EditTextCell) is undefined" – Chris Jun 08 '11 at 09:41
  • I'm wondering if this also ensure that you cannot copy-PASTE non-numeric values, I guess if as you say, on every keydown, you check the whole field's value and verify if that's numeric, it'll work perfect. – dominicbri7 Jun 08 '11 at 14:21
  • You definitely need to do both: supressing keys ensures that you don't type values in, and copy&paste has to be checked on Value change – Chris Jun 09 '11 at 15:27