[英]GWT Celltable How to make Non-Editable cell in Editable column
I added EditTextCell(stringTestEditTextCell) to Column(testColumn). 我添加了EditTextCell(stringTestEditTextCell)到Column(testColumn)。
EditTextCell editTextCell = new EditTextCell(); EditTextCell editTextCell = new EditTextCell(); Column stringColumn = new Column( editTextCell) { @Override public String getValue(Record object) { 列stringColumn = new Column(editTextCell){@Override public String getValue(Record object){
return object.getValue();
}
};
All cells in testColumn are editable. testColumn中的所有单元格都是可编辑的。
I want 1st cell of column such way that 1st cell of column should be Non-Editable. 我想要列的第一个单元格这样列的第一个单元格应该是不可编辑的。
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);
}
}
}
您可以扩展EditTextCell并覆盖edit()-Method,以便仅在未设置需要为第一个单元格设置的布尔标志时才进行编辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.