View Full Version : Form and Record best practices?

7 Feb 2012, 8:57 AM
We currently have a situation where we have a record bound to a form using loadRecord. When we change one field on the form there is an event tied to that field which says to update 3 other fields. Two of these fields are physical fields in the form and the other is a field in the model instance / record. What I would like to know is should we be updating the entire record to keep the form and record in sync? Also, when we update a field in the form should we also be updating the record with the new value?

7 Feb 2012, 12:45 PM
You can sync the model and form when a field change event happens or when the user clicks a button. Two valid ways, up to you.

7 Feb 2012, 3:08 PM
Michell thanks for the response. I am trying to work out some form issues and that does help. but.....

Lets say I have a form with 50 fields. In the controller I attach a textfield event like so (assuming I used the correct component query).


Aside from having 50 Fields, would there be a performance impact for attaching this event on all fields? As I understand it from checkChange() function in Ext.form.field.Field class, the event is listened for automatically so it doesn't appear to have an impact (unless I did some craziness inside of the change event). Is my assumption correct?

checkChange: function() {
if (!this.suspendCheckChange) {
var me = this,
newVal = me.getValue(),
oldVal = me.lastValue;
if (!me.isEqual(newVal, oldVal) && !me.isDestroyed) {
me.lastValue = newVal;
me.fireEvent('change', me, newVal, oldVal);
me.onChange(newVal, oldVal);

My understanding of the fireEvent function in this situation is to basically allow you to make some function call and do some processing before the onChange event is executed. Is this correct?