2011-03-15 82 views
1
CellList<Device> cellList = new CellList<Device>(new ItemCell()); 

其中:GWT CellList编辑细胞

static class ItemCell extends AbstractCell<Device> { 
    @Override 
    public void render(Context context, Device device, SafeHtmlBuilder builder) { 
     if(device == null) { 
      return; 
     } 
     builder.appendHtmlConstant("<div>device.getId()</div>"); 
     builder.appendHtmlConstant("<div>device.getName()</div>"); 
    } 
} 

而现在,我想打一个“编辑”按钮,当我将它按 - 我想看看编辑选择的项目。我该怎么做?请回答,谁知道。

回答

0

我也跟着这样做的简单的老办法。

我使用了一个单元格列表和附加的表单。每当你点击一行时,行的数据就被加载到表单中。您现在可以通过此表格删除或编辑选定的行。

1

使用EditTextCell或ActionCell

 

addColumn(new EditTextCell(), "Name", new GetValue() { 
      @Override 
      public String getValue(IData contact) { 
       return contact.getName(); 
      } 
     }, new FieldUpdater() { 
      @Override 
      public void update(int index, IData object, String value) { 
       try { 
        pandingChanges.add(new FirstNameChange(object, value)); 
       } catch (Exception e) { 
       }

} });

检查this出或>THIS>

+0

谢谢,先生。宋体。但是我有一个CellList,而不是CellTable,CellList中的方法addColumn()是什么? – Andrew 2011-03-15 12:40:51