Hybrid View
-
8 Oct 2010 12:33 PM #1
BasicForm.reset: Resets to default values?
BasicForm.reset: Resets to default values?
If I have a form without any values / defaults declared and I .getForm().setValues() on it before I show the form, those values become defaults. Why?
Here's a sample demo. If you click "Show the window" first, then the buttons work. If you click "Load some values" first, then the form never seems to reset no matter what button you click after that.
Thanks.
Code:Ext.onReady(function () { var mWin = new Ext.Window({ title: "My Window", width: 350, padding: 10, height: 200, border: false, modal: true, resizable: false, layout: 'fit', closeAction: 'hide', listeners: { hide: function() { this.items.get(0).getForm().reset(); } }, items:[{ xtype: 'form', labelWidth: 150, defaults: { width: 150 }, items:[{ xtype: 'textarea', fieldLabel: 'Why?', name: 'why' }, { xtype: 'numberfield', fieldLabel: "How many?", name: 'how' }] }] }); var bWin = new Ext.Window({ width: 250, height: 150, resizable: false, layout: 'fit', title: 'This is a test.', items: [{ xtype: 'label', text: 'This is only a test' }], buttons:[{ text: 'Show the window', handler: function() { mWin.show(); } }, { text: 'Load Some Values', handler: function() { var bForm = mWin.items.get(0).getForm(); bForm.setValues({ 'why': 'I think', 'how': 42 }); mWin.show(); } }] }); bWin.show(); });Last edited by darthwes; 8 Oct 2010 at 5:57 PM. Reason: You need to start getting real specific...
Wes
-
8 Oct 2010 7:28 PM #2
The originalValue property on each fields is set at rendering time meaning that if you load values before the form gets loaded, those values becomes original values.
-
8 Oct 2010 10:27 PM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Correct. If you define all your fields with a 'value' that value will become the originalValue.
-
28 Oct 2010 2:16 AM #4
Hi,
i have a similar problem.
I have a form in which I load some datas.
;PHP Code:this.load(
url: ...
)
If I call the reset() method, it clears all the data... but I would like to bring them to the last load.
Is that possible?
tnx al
-
28 Oct 2010 2:46 AM #5
-
28 Oct 2010 2:54 AM #6
Similar Threads
-
Ext.BasicForm.reset dumps original values for hidden fields
By wwarby in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 24 Nov 2009, 12:21 PM -
[SOLVED] Radio not reset to their default values
By senacle in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 2 Jul 2009, 12:18 AM -
[2.2][CLOSED] BasicForm.updateRecord updates clears values
By igo in forum Ext 2.x: BugsReplies: 2Last Post: 3 Oct 2008, 5:48 AM -
BasicForm.reset() does not clear fields?
By dante in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 30 May 2008, 4:14 AM -
Form fields reset to default on submitting
By LorenzoW in forum Ext 1.x: Help & DiscussionReplies: 2Last Post: 30 Apr 2007, 6:42 AM


Reply With Quote
