Extending a class like ListStoreEditor wouldn't be my first choice - I'd tend to encourage composition over inheritance, unless this specific setup is going to be reused quite frequently.
I'm also not understanding why the EditableGrid (which implements Editor) has an internal Driver - shouldn't this be *part* of the form rather than its own distinct editor?
Design issues aside, your problem is almost certainly that you never call flush() on the driver. My guess is that there is also an outer driver, and that this mix of two different drivers talking to this same sub-editor is where the confusion is coming from.
Check out this example http://www.sencha.com/examples/#Exam...ropertybinding especially in the contents of the PersonEditor class. Here's a slightly modified version of that class with a CheckBoxSelectionModel and a button to delete selected items, based roughly on your loop code. I can't run your code (missing EntityDto, plus whatever containing editor/form you've got), so this is the closest I can do to suggest. I think this would even be a good idea to add to the official example.
Code:
public class PersonEditor implements IsWidget, Editor<Person> {
interface KidProperties extends PropertyAccess<Kid> {
@Path("id")
ModelKeyProvider<Kid> key();
ValueProvider<Kid, String> name();
ValueProvider<Kid, Integer> age();
}
private static final KidProperties props = GWT.create(KidProperties.class);
TextField name = new TextField();
TextField company = new TextField();
TextField location = new TextField();
NumberField<Double> income = new NumberField<Double>(new DoublePropertyEditor());
ListStore<Kid> kidStore = new ListStore<Kid>(props.key());
ListStoreEditor<Kid> kids = new ListStoreEditor<Kid>(kidStore);
@Override
public Widget asWidget() {
FlowPanel container = new FlowPanel();
// should be layout based
int w = 275;
name.setWidth(w);
company.setWidth(w);
location.setWidth(w);
income.setWidth(w);
container.add(new FieldLabel(name, "Name"));
container.add(new FieldLabel(company, "Company"));
container.add(new FieldLabel(location, "Location"));
container.add(new FieldLabel(income, "Income"));
List<ColumnConfig<Kid, ?>> columns = new ArrayList<ColumnConfig<Kid,?>>();
final CheckBoxSelectionModel<Kid> selection = new CheckBoxSelectionModel<Kid>(new IdentityValueProvider<Kid>());
selection.setSelectionMode(SelectionMode.MULTI);
columns.add(selection.getColumn());
ColumnConfig<Kid, String> name = new ColumnConfig<Kid, String>(props.name(), 200, "Name");
columns.add(name);
ColumnConfig<Kid, Integer> age = new ColumnConfig<Kid, Integer>(props.age(), 100, "Age");
columns.add(age);
final Grid<Kid> grid = new Grid<Kid>(kidStore, new ColumnModel<Kid>(columns));
grid.setBorders(true);
grid.setSelectionModel(selection);
grid.getView().setForceFit(true);
GridInlineEditing<Kid> inlineEditor = new GridInlineEditing<Kid>(grid);
inlineEditor.addEditor(name, new TextField());
inlineEditor.addEditor(age, new NumberField<Integer>(new IntegerPropertyEditor()));
grid.setWidth(382);
grid.setHeight(200);
FieldLabel kidsContainer = new FieldLabel();
kidsContainer.setText("Kids");
kidsContainer.setLabelAlign(LabelAlign.TOP);
kidsContainer.setWidget(grid);
container.add(kidsContainer);
container.add(new TextButton("Delete selected rows", new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
for (Kid entityToDelete : selection.getSelectedItems()) {
kidStore.remove(entityToDelete);
}
}
}));
return container;
}
}
I also modified the example itself to display the results after flush() was called to show that the kids list was correct:
Code:
panel.addButton(new TextButton("Save", new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
Person p = driver.flush();
new MessageBox(p.getKids().size() + " kids").show();
}
}));