gxt 2.2.5 changing row editor state

432 Views Asked by At

Using GWT + GXT. Is it possible to change an active row editor state by eg messagebox? I created an event which calls a messagebox with text area and in order to put text from that textarea into grid i need to call rowEditor.stopEditing(true), then manually insert text into data grid, and then perform rowEditor.startEditing(true). So it look like:

re.stopEditing(true);
List<Model> list = data.getModels();
list.get(activeRow).set("key","value");
re.startEditing(activeRow, true);

And it works... But user can not cancel his changes if needed, because they were already saved by re.stopEditing(true);

1

There are 1 best solutions below

0
On

It sounds like if stopEditing causes a state change you don't want (saved changes), and there is no other API to skip that side effect, then there are a few potential options (as I'm not familiar with this library, I'll be speaking to the general pattern):

  1. Do not call it on the "real" model: Use a clone/copy to do all the work, then when the changes are to be committed, save the changes to the real model.
  2. Can you store the "original" state of the model before any editing takes place at all? Then it doesn't matter how many intermediate saves are done via stopEditing, you could implement a cancel operation just by restoring the original model.
  3. If both of those aren't possible, there is a more complex option - look into the source code for stopEditing - can you extend the class to override this method, removing the undesired functionality? If there are a bunch of private variables involved, you can always expose them to your extension via reflection, or make your extension as detailed as necessary to cover the changes.

Hopefully one of these will be able to apply to your situation.