PDA

View Full Version : Ext.form.Basic.reset(true) retains record values



winkelmann
6 Feb 2013, 3:03 AM
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 :-)

sword-it
6 Feb 2013, 7:13 AM
Hi,
you can see this link:http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.BasicForm-method-reset , http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.BasicForm-method-reset

winkelmann
6 Feb 2013, 7:21 AM
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.

winkelmann
7 Feb 2013, 1:37 AM
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.


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();

Jangla
21 May 2013, 11:04 AM
Just adding my own post here to get updates as I'm seeing the same problem