Threaded View

  1. #1
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    633
    Vote Rating
    -11
    darthwes can only hope to improve

      0  

    Cool 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

Similar Threads

  1. Ext.BasicForm.reset dumps original values for hidden fields
    By wwarby in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 24 Nov 2009, 12:21 PM
  2. [SOLVED] Radio not reset to their default values
    By senacle in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 2 Jul 2009, 12:18 AM
  3. Replies: 2
    Last Post: 3 Oct 2008, 5:48 AM
  4. BasicForm.reset() does not clear fields?
    By dante in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 30 May 2008, 4:14 AM
  5. Form fields reset to default on submitting
    By LorenzoW in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 30 Apr 2007, 6:42 AM

Thread Participants: 4