Threaded View

Answered: Grid in a form

Hey guys,

first of all congrats on the great product. I am, however, stuck on a problem I cannot solve already a few days. I implemented a window with different fields in it (TextField, HtmlEditor, SpinnerFields, etc.) and I used driver so that when the user clicks on the save button to pass his data to a GWT RPC service. This all worked great, so I decided to throw a Grid in the mix. The grid has a context menu with Add and Remove MenuItems and I want to add/remove rows from the grid. Again it all works good - the context menu is shown and when Remove is selected, all I do is get the selected entities in the grid, iterate over them and remove them from the store:

After that the items are moved from the grid, but as soon as I hit Save I see that the server receives ALL of the items - the original collection. I somehow am not able to pass the new collection to the server.
Here's my grid implementation (I extend ListStoreEditor for what matters):

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.