masterdany88
masterdany88

Reputation: 5341

GWT cell table, how to clear input of EditTextCell?

I have column with EditTextCell. I some condition I would like to clear data from that cell.

In column FieldUpdater in method update I do some checks.

How I can clear this data in update method?

Upvotes: 0

Views: 469

Answers (1)

Adam
Adam

Reputation: 5599

You need to clearViewData and redrawRow:

final CellTable<MyTableType> table = new CellTable<MyTableType>();

final MyEditTextCell cell = new MyEditTextCell();

Column<MyTableType, String> column = new Column<MyTableType, String>(cell) {
    @Override
    public String getValue(MyTableType object) {
        if(object.getValue() == null)
            return "";
        else
            return object.getValue();
    }
};
column.setFieldUpdater(new FieldUpdater<MyTableType, String>() {
    @Override
    public void update(int index, MyTableType object, String value) {
        if(Window.confirm("Replace with \"" + value + "\"?"))
            object.setValue(value);
        else {
            cell.clearViewData(object);
            table.redrawRow(index);
        }
    }
});

Upvotes: 2

Related Questions