2011-10-31 75 views
1

我將EditTextCell(stringTestEditTextCell)添加到列(testColumn)。GWT Celltable如何使可編輯列中的非可編輯單元格

EditTextCell editTextCell = new EditTextCell(); 柱stringColumn =新柱( editTextCell){ @覆蓋 公共字符串的getValue(記錄對象){

  return object.getValue(); 
     } 
    }; 

在testColumn所有細胞是可編輯的。

我想列的第一個單元格的列的第一個單元格應該是Non-Editable。

+0

該列的第一個單元格是不可編輯的?你的意思是頭部?爲什麼不是頭? –

+0

是第1列的第1個單元格不可編輯 – StackOverFlow

回答

1

下面的課是回答我的問題。我解決了它,工作正常。但是當用戶點擊列的第一個單元格時出現錯誤。

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

您可以擴展EditTextCell並覆蓋edit()-Method,以便只在您未設置需要爲第一個單元格設置的布爾標誌時才進行編輯。

相關問題