Maybe somebody is calling a method like Canvas.addKeyPressHandler () to intercept the Enter key.
Then after receiving the event, they are calling KeyPressEvent.cancel () which might prevent the Enter key from reaching the form... Just a guess.
But FYI, the sample I posted earlier has always worked for me, and now I am using SmartGWT 4.0 from 2013-11-30, and it's working with that build as well.
Announcement
Collapse
No announcement yet.
X
-
Hi Blama,
Thanks for your reply, I tried your code. I dont know why but addSubmitValuesHandler is not triggered at all. The form does not gets destroyed.
But there should be a submit event triggered when we setsaveonenter is true. And if its overridden then we can destroy the pop up window after the data is saved. Some where I am missing it .. :(
Leave a comment:
-
Hi GSel,
without testing: Try something like:
Not sure about the first two lines. Read the docs of these and try.Code:yourForm.setSaveOnEnter(true); yourForm.setCanSubmit(false); yourForm.addSubmitValuesHandler(new SubmitValuesHandler() { public void onSubmitValues(final SubmitValuesEvent submitValuesEvent) { yourForm.saveData(); //Check for success yourWindow.destroy(); } });
Best regards,
Blama
Leave a comment:
-
Destroy the Form in the pop up window after setSaveOnEnter(true);
I have a add button in my ToolsStrip. When clicked on add button there pop s up a dynamic form window, after fetching the data and enter is clicked the data in my form gets saved (data is seen in the background grid). But the Dynamic Form in the pop up window does not gets destroyed.
Is there any handler/any way to destroy the window once data is being saved by clicking enter ?
Thanks in advance.
Leave a comment:
-
Hi shortpasta,
thanks a lot. Exactly what I was looking for.
I now do:
andCode:final IButton newBtn = new IButton("Add:", new ClickHandler() { @Override public void onClick(ClickEvent event) { newForm.saveData(); } });
Code:final DynamicForm newForm = new DynamicForm() { @Override public void saveData() { super.saveData(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (Helper.oneRow(response)) { clearValue(getDataSource().getPrimaryKeyFieldName()); } } }); } { setDataSource(telefonDS); setNumCols(6); setSaveOnEnter(true); setCanSubmit(false); addSubmitValuesHandler(new SubmitValuesHandler() { public void onSubmitValues(final SubmitValuesEvent submitValuesEvent) { saveData(); } }); ...
Leave a comment:
-
This is the way I have always done it & it works in 3.0:
I don't remember why I started doing it this way.Code:// configure the form for enter-key autosubmission form.setSaveOnEnter (true); form.addSubmitValuesHandler (new SubmitValuesHandler () { public void onSubmitValues (final SubmitValuesEvent submitValuesEvent) { executeDefaultAction (); } });
Maybe the docs used to say to do it this way, or maybe I saw it somewhere.
Maybe this is enough to get you going for now...
Leave a comment:
-
Hi Isomorphic,
I'm having the same problem as mihai007.
I have following code in an anonymous subclass of DynamicForm with setSaveOnEnter(true) and setCanSubmit(false).
If I use a Button with a ClickEvent-Callback to save(), my @Override method is accessed (all the methods have breakpoints). On ENTER, no breakpoint is hit. How can I interfere in the save-process of ENTER in order to add a DSCallback handler?
Thanks,Code:@Override public void saveData() { super.saveData(); } @Override public void saveData(DSCallback callback) { super.saveData(callback); } @Override public void submit() { super.submit(); }
Blama
Leave a comment:
-
Just a typo in the topic's title, it should be submit(), not save():
"Form.setSaveOnEnter() is not calling submit() as being said."
Leave a comment:
-
Form.setSaveOnEnter() is not calling save() as being said.
Hello.
Actually I can't understand what method is being called if I use
None of the below methods are being calledCode:form.setSaveOnEnter(true);
P.S: the save is actually being done to the datasource...Code:DataSource dataSource = new DataSource(); dataSource.setClientOnly(true); DataSourceTextField dsField = new DataSourceTextField("Field"); dataSource.setFields(dsField); final DynamicForm form = new DynamicForm() { @Override public void submit() { System.out.println("sublit"); } @Override public void submit(DSCallback callback) { System.out.println("sublit"); } @Override public void submit(DSCallback callback, DSRequest requestProperties) { System.out.println("sublit"); } @Override public void saveData() { System.out.println("sublit"); } @Override public void saveData(DSCallback callback) { System.out.println("sublit"); } @Override public void saveData(DSCallback callback, DSRequest requestProperties) { System.out.println("sublit"); } @Override public void submitForm() { System.out.println("sublit"); } }; form.setDataSource(dataSource); form.setSaveOnEnter(true); VLayout vLayout = new VLayout(); vLayout.setMembersMargin(10); vLayout.addMember(form); vLayout.draw();Tags: None
Leave a comment: