View Full Version : RowEditor capture the button clicks

6 Sep 2011, 1:21 AM
Hey at all

I have a question about the RowEditor. I have a Grid with the RowEditor and I would like to make some checks on the Fields befor I save the row.
normaly I do this with the afterEdit-Event or cancelEdit-Event but if I startEditing and click directly after that the save-Button the two Events don't take effect.

Where is the mistake? Which Event should I try?

6 Sep 2011, 3:10 AM
If there are no changes and the RowEditor is in a valid state, than the RowEditor is just hidden. Take a look at the stopEditing method.

6 Sep 2011, 3:20 AM
I don't get it. What has the Method stopEditing to do with the Events?
I need a Event if the Editor hide. Or I need a Event if the Save or Cancel Button are activatet.

6 Sep 2011, 3:21 AM
I don't get it. What has the Method stopEditing to do with the Events?

This method fires the events.

6 Sep 2011, 3:22 AM
But I don't use this method.

6 Sep 2011, 3:23 AM
It gets called internly when clicking on the buttons.

6 Sep 2011, 3:25 AM
Is there a possibillity that I can Override the Save-Button?

6 Sep 2011, 3:27 AM
You can change anything you want to change. You can extend RowEditor and add your own features and changes. As i said, i would start taking a look at this method to understand how any why the events are fired currently. You maybe also want to look at createButtons

6 Sep 2011, 3:40 AM
I debugged the method and I know now that no Event is fired.

if (!saveChanges || !isValid()) {
fireEvent(Events.CancelEdit, ree);
} else if (hasChange && fireEvent(Events.ValidateEdit, ree)) {
for (String k : data.keySet()) {
record.set(k, data.get(k));
fireEvent(Events.AfterEdit, ree);
What can I do now? Override this method?

6 Sep 2011, 3:41 AM
That is what i told you. The method is not firing an event because the editor is valid and there is no change.

Now there are two solutions:
1) Change the logic of this method so it fits your needs
2) Create some completly differetn logic when clicking on the save button.

6 Sep 2011, 4:21 AM
I think your first solution is better. Can I change the code in the class-File or must I make a new class?

6 Sep 2011, 4:24 AM
This depends on what you want to do. I would never do this kind of change in a library file.

6 Sep 2011, 4:26 AM
Ok. Then I must create a new class wich extends the RowEditor or not?

But how can I override the method than?

6 Sep 2011, 4:32 AM
Ok. Then I must create a new class wich extends the RowEditor or not?

Yes exactly

6 Sep 2011, 4:36 AM
And how can I override the method then? I know with @Override but how can I use the Variables of the RowEditor-class?

6 Sep 2011, 4:39 AM
Sorry i cannot help you with this.

It works exactly as in any other java application.

6 Sep 2011, 4:40 AM
Ok, thanks.

6 Sep 2011, 4:50 AM
it is not possible to override the method because all needed variables are private in the roweditor-class and have no setter oder getter methods.

I hope I figure something else out.

6 Sep 2011, 4:52 AM
You can use JSNI to access these members

6 Sep 2011, 5:00 AM
Ah ok, but I figured something else. In my case the Event "hide" is enough. there I can make my needed checks.
Thank you very much for the fast help :)

6 Sep 2011, 5:02 AM
The hide event will be called in many different cases too, not only when clicking the save button. Also clicking the save button mabe not fire the hideevent at all.

6 Sep 2011, 11:21 PM
no problem in my case it works perfect.