View Full Version : RowEditor capture the button clicks
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?
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.
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.
I don't get it. What has the Method stopEditing to do with the Events?
This method fires the events.
But I don't use this method.
It gets called internly when clicking on the buttons.
Ok.
Is there a possibillity that I can Override the Save-Button?
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
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)) {
record.beginEdit();
for (String k : data.keySet()) {
record.set(k, data.get(k));
}
record.endEdit();
fireEvent(Events.AfterEdit, ree);
}
hide();
What can I do now? Override this method?
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.
I think your first solution is better. Can I change the code in the class-File or must I make a new class?
This depends on what you want to do. I would never do this kind of change in a library file.
Ok. Then I must create a new class wich extends the RowEditor or not?
But how can I override the method than?
Ok. Then I must create a new class wich extends the RowEditor or not?
Yes exactly
And how can I override the method then? I know with @Override but how can I use the Variables of the RowEditor-class?
Sorry i cannot help you with this.
It works exactly as in any other java application.
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.
You can use JSNI to access these members
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 :)
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.
Ceene
6 Sep 2011, 11:21 PM
no problem in my case it works perfect.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.