Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Can't get form.getForm().reset() to work

  1. #1
    Ext User
    Join Date
    May 2008
    Posts
    12
    Vote Rating
    0
      0  

    Default Can't get form.getForm().reset() to work

    Hi,

    I'm having problems with form reset... i have a form that is used for add (no initial values) and for edit. The problem is that if edit a register first, when i open the add form, it has the values from the last edition... even if i call form.getForm().reset().

    I also tried with trackResetOnLoad true or false... but the problem is always the same... can anybody help please! I'm using ExtJs 2.1.

    Thanks in advance
    Carlos

  2. #2
    Sencha User
    Join Date
    May 2008
    Posts
    17
    Vote Rating
    0
      0  

    Default

    please post your form code (including button config). impossible to answer unless we can see what your doing.

    thanks

  3. #3
    Ext User
    Join Date
    May 2008
    Posts
    12
    Vote Rating
    0
      0  

    Default

    Thanks for reply... here's the code... when doing reset, the form come up with the last values that were filled during edit action (basic setValues for all fields).

    =====

    var grid = new Ext.grid.GridPanel({
    <several grid options here>
    tbar:[{
    text:'Add Payment',
    tooltip:'Add a new payment',
    iconCls:'add',
    handler: function(){
    form.getForm().reset();
    formWindow.setTitle('Add Payment');
    formWindow.show();
    AddSubmitButton.show();
    EditSubmitButton.hide();
    f1DateField.setValue(new Date());
    }
    }]
    });

    grid.render();

    var form = new Ext.form.FormPanel({
    baseCls: 'x-plain',
    labelWidth: 60,
    monitorValid: true,
    items: [f1DateField, f2MethodField, f3AmountField, f4RefField],
    buttons: [AddSubmitButton, EditSubmitButton,
    {
    text: 'Cancel',
    handler: function(){
    FormWindow.hide();
    }
    }]
    });

    var formWindow = new Ext.Window({
    width: 275,
    height:225,
    modal: true,
    layout: 'fit',
    plain:true,
    loadMask: true,
    bodyStyle:'padding:5px;',
    buttonAlign:'center',
    items: [form],
    closable: false,
    resizable: false
    });

    ====

    Thanks
    Carlos V.

  4. #4
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    3
      0  

    Default

    try moving your form reset to after the window is shown.

  5. #5
    Ext User
    Join Date
    May 2008
    Posts
    12
    Vote Rating
    0
      0  

    Default

    Unfortunately i tried that before without success

  6. #6
    Ext User
    Join Date
    Jan 2009
    Posts
    9
    Vote Rating
    0
      0  

    Default form.getForm().reset() doesn't reset the form

    I 'm having the same problem, no answer to this thread from support team??????

  7. #7
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    3
      0  

    Default

    Quote Originally Posted by Sina View Post
    I 'm having the same problem, no answer to this thread from support team??????
    http://extjs.com/learn/Ext_Forum_Help
    http://extjs.com/learn/Ext_Forum_Hel...rking_showcase

  8. #8
    Sencha User Izhaki's Avatar
    Join Date
    Apr 2009
    Location
    London
    Posts
    118
    Vote Rating
    13
      0  

    Default

    I had the same problem.

    Added this to the formPanel to solve it:

    Code:
    // a hack to get reset() to work
    resetFields: function()
    {
     formPanel.findBy(function(comp){if (comp.fieldLabel) comp.reset();}); 
    },

  9. #9
    Sencha User
    Join Date
    Apr 2009
    Posts
    3
    Vote Rating
    0
      0  

    Default

    I have managed to find a workaround, simply by setting values of the form, after I call show() method of the window. This way the form is first rendered with no values set, and its initial state contains empty fields. Since reset() method always returns to the initial state, this sequence works fine.

    Hope this helps.
    Happy new year to you all.

  10. #10
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Amsterdam, The Netherlands
    Posts
    245
    Vote Rating
    6
      0  

    Default

    Quote Originally Posted by Izhaki View Post
    I had the same problem.

    Added this to the formPanel to solve it:

    Code:
    // a hack to get reset() to work
    resetFields: function()
    {
     formPanel.findBy(function(comp){if (comp.fieldLabel) comp.reset();}); 
    },

    Thanks! They should fix this anyway...

    And it doesn't work with defferedRender = true

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •