GWT Celltable : How to avoid entering particular value in particular cell of Celltable?

1.1k views Asked by At

How to avoid entering particular value in editTextCell- column- Celltable?

Is there any event in editTextCell?

Validation while entering values in cells of celltable
In case of
String :Dont enter spaces in cell
Integer : Dont use characters

  • avoiding spaces in cell i.e if cell is type of string then user can't use spaces for although user presses "space bar" button multiple times then that spaces should not be enter in cell a How to achieve this ?

Any help or guidance in this matter would be appreciated.

2

There are 2 answers

3
Thomas Broyer On

If you want a specific behavior in a Cell, then you have a to make a Cell with that behavior built in.

You could start with an EditTextCell if that's what you want, and then extend it and override its onBrowserEvent to cancel key events for spaces when in edit mode, or something like that.

0
StackOverFlow On

Here is the answer with sample code :)
KeyCode of SpaceBar 32

 @Override
            public void onBrowserEvent(Context context, Element parent,
                    String value, NativeEvent event,
                    ValueUpdater<String> valueUpdater) {
                super.onBrowserEvent(context, parent, value, event, valueUpdater);
                boolean isEditing = isEditing(context, parent, value);

                if(isEditing){
                    if(event!=null){
                        info(" event.getKeyCode() = "+event.getKeyCode()+" :: value ="+value);
                        if(event.getKeyCode()==32)){
                            event.preventDefault();
                            return;
                        }
                    }
                }
            }