GWT 2.5 DataGrid SelectionModel with Subrows
Asked Answered
W

1

6

When using TableBuilder to create rows and sub rows, selection model isn't working as expected. When clicking on a subrow's checkbox the row isn't been selected, however, the parent row become selected instead.

I tried to overload onBrowserEvent of the CheckboxCell in order to manually handle the selection but it seems that the DataGrid itself fires the selection event when pressing the checkboxcell.

In case where rows and subrows are from the same type, how can I add selection model that supports both rows and subrows?

Wondrous answered 31/7, 2012 at 15:56 Comment(1)
Want to add some of your impl? Perhaps it would help spur more help.Falkirk
F
0
@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);
}
Florencio answered 25/5, 2013 at 4:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.