1. #1
    Ext User
    Join Date
    May 2008
    Posts
    12
    Vote Rating
    0
    cvieira is on a distinguished road

      0  

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

    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
    ktilt is on a distinguished road

      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
    cvieira is on a distinguished road

      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
    0
    devnull has a little shameless behaviour in the past

      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
    cvieira is on a distinguished road

      0  

    Default


    Unfortunately i tried that before without success

  6. #6
    Ext User
    Join Date
    Jan 2009
    Posts
    9
    Vote Rating
    0
    Sina is on a distinguished road

      0  

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

    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
    4
    tryanDLS is on a distinguished road

      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
    Izhaki will become famous soon enough

      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
    altmisdort is on a distinguished road

      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
    Grolubao is on a distinguished road

      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