GWT Celltable How to make Non-Editable cell in Editable column

1.9k Views Asked by At

I added EditTextCell(stringTestEditTextCell) to Column(testColumn).

EditTextCell editTextCell = new EditTextCell(); Column stringColumn = new Column( editTextCell) { @Override public String getValue(Record object) {

            return object.getValue();
        }
    };

All cells in testColumn are editable.

I want 1st cell of column such way that 1st cell of column should be Non-Editable.

2

There are 2 best solutions below

0
On BEST ANSWER

Following class is answer to my question. I Solved it and works fine. But getting error when user clicking on 1st cell of column.

class CustomEditTextCell extends EditTextCell{
    @Override
    public void render(com.google.gwt.cell.client.Cell.Context context,
            String value, SafeHtmlBuilder sb) {
        // context.getColumn()==2 indicate Record ID column and context.getIndex()==0 indicate non editable cell in 1st empty row
        if(context.getColumn()==2 &&    ( context.getIndex()==0  || context.getIndex()%10 == 0)){
            sb.appendHtmlConstant("<div contentEditable='false' unselectable='true'></div>");
        }else{
        super.render(context, value, sb);
        }

    }
}
0
On

You might extend EditTextCell and override the edit()-Method so that it only edits when you have not set a boolean flag that you that you need to set for the first cell.