为了逼退创建FieldUpdater特定的列/页更改您的Domain对象。然后在您的按钮的onClick回调中使用第一行的值更新您的List。
例如,对于其中需要MyDTO类的任意TextInputColumn(可以是任何域对象)作为值类型可以定义以下FieldUpdater:
myColumn.setFieldUpdater(new FieldUpdater() {
@Override
public void update(int index, MyDTO object, String value) {
// Push the changes into the MyDTO. At this point, you could send an
// asynchronous request to the server to update the database.
object.someField = value;
// Redraw the table with the new data.
table.redraw();
}
});
必须设置这样的FieldUpdater所有5列。 (someField是您要更新的DTO中的字段)。
现在,在按钮的onClick()回调函数中,您必须更新实际列表。看起来像这样:
update_column_cell.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
//Supose listDataProvider is the instance of your DataSource for your CellTable
List<MyDTO> list = listDataProvider.getList();
// get cell values for the first row (this is for one cell)
newSomeField = list.get(0).someField;
newSomeField2 = list.get(0).someField2;
for (int i = 1;i<list.size();i++) {
MyDTO dto = list.get(i);
if (newSomeField != null && newSomeField.isNotEmpty()) {
dto.someField = newSomeField;
}
if (newSomeField2 != null && newSomeField2.isNotEmpty()) {
dto.someField2 = newSomeField2;
}
}
}
})
这个例子只处理你的DTO的两个领域。您可能需要扩展它以覆盖您在CellTable中显示为列的所有5个字段