当使用TableBuilder创建行和子行时,选择模型不能按预期工作。当单击子行的复选框时,该行未被选中,但父行变为选中状态。
我试图重载CheckboxCell的onBrowserEvent以手动处理选择,但似乎DataGrid本身在按下复选框单元格时会触发选择事件。
如果行和子行来自同一类型,如何添加既支持行又支持子行的选择模型?
发布于 2013-05-25 12:47:21
@Override
public void onBrowserEvent(Context context, Element elem, final T object,
NativeEvent event) {
// The provided row is always the root row, so we need to find the
// correct one when a sub row was edited
actualIndex = context.getSubIndex();
actualObject = object;
if (0 != context.getSubIndex() && object instanceof RowDTO) {
actualIndex = context.getSubIndex();
actualObject = (T) ((RowDTO) object).getChild(actualIndex - 1);
context = new Context(context.getIndex(), context.getColumn(),
actualObject, actualIndex);
}
ValueUpdater<C> valueUpdater = (getFieldUpdater() == null) ? null
: new ValueUpdater<C>() {
@Override
public void update(C value) {
getFieldUpdater().update(actualIndex, object, value);
}
};
getCell().onBrowserEvent(context, elem, getValue(actualObject), event,
valueUpdater);
}https://stackoverflow.com/questions/11744198
复制相似问题