Results 1 to 5 of 5

Thread: Ext.form.Basic.reset(true) retains record values

  1. #1
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Hamburg, Germany
    Posts
    196
    Answers
    1
    Vote Rating
    7
      0  

    Default Unanswered: Ext.form.Basic.reset(true) retains record values

    I have a form with trackResetOnLoad=true that I load a record into with loadRecord(). If I then reset the form with resetRecord=true, it deletes the record internally, but it does not reset the form to actual empty values.

    In my oppinion if i have the form bound to a record via trackResetOnLoad, the form fields should be reset to empty values rather than having to fix the values manually.

    Any insight is appreciated :-)

  2. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124
    Vote Rating
    90
      0  
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Hamburg, Germany
    Posts
    196
    Answers
    1
    Vote Rating
    7
      0  

    Default

    I know about the reset function, thats what I'm complaining about ;-) You linked to Ext3 docs by the way, I'm using 4. My problem is that if I call reset(true) on the form, it resets the form to the original values provided by the record i loaded into it using loadRecord(), rather than resetting it to either empty values or the values the form had before loading the record.

  4. #4
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Hamburg, Germany
    Posts
    196
    Answers
    1
    Vote Rating
    7
      0  

    Default

    I created a little test case to reproduce the effect. Simply click on the grid record to load it into the form, then click reset. The form data will not change because the fields original value was reset by trackResetOnLoad=true, when removing the record, the field still retains the value though.

    Code:
    Ext.define('TestWindow', {
        extend: 'Ext.window.Window',
    
        onGridSelectionChange: function(g, recs) {
            this.down('form').loadRecord(recs[0]);
        },
    
        onResetBtnClick: function() {
            this.down('form').getForm().reset(true);
        },
    
        initComponent: function() {
            var me=this;
    
            me.items = [{
                flex: 1,
                xtype: 'grid',
                store: me.store,
                columns: [{
                    flex: 1,
                    dataIndex: 'test',
                    header: 'Test'
                }],
                listeners: {
                    scope: me,
                    selectionchange: me.onGridSelectionChange
                }
            },{
                xtype: 'form',
                flex: 1,
                trackResetOnLoad: true,
                items: {
                    columnWidth: 0.4,
                    margin: '10',
                    autoScroll: true,
                    xtype: 'fieldset',
                    title: 'Edit entry',
                    defaultType: 'textfield',
                    items: [{
                        fieldLabel: 'Test',
                        name: 'test'
                    }]
                }
            }];
    
            me.dockedItems = [{
                xtype: 'toolbar',
                dock: 'bottom',
                items: [{
                    text: 'Reset form',
                    scope: me,
                    handler: me.onResetBtnClick
                }]
            }];
    
            me.callParent();
        },
    
        constructor: function() {
            this.store = Ext.create('Ext.data.Store', {
                fields: ['test'],
                data: [{test: 'Field data'}]
            })
    
            this.callParent([{
                width: 300,
                height: 300,
                layout: {
                    type: 'vbox',
                    align: 'stretch'
                }
            }]);
        }
    });
    
    Ext.create('TestWindow').show();

  5. #5
    Ext JS Premium Member
    Join Date
    Feb 2009
    Posts
    487
    Answers
    4
    Vote Rating
    5
      0  

    Default

    Just adding my own post here to get updates as I'm seeing the same problem

Posting Permissions

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