-
20 Jun 2012 1:28 AM #1
BasicForm reset should remove reference to _record
BasicForm reset should remove reference to _record
Ext version tested:
- Ext 4.1
Browser versions tested against:- Chrome 21
DOCTYPE tested against:- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Description:- I am using the same instance of a form to create and update data in a store. When I update, i use loadRecord() to load data from an existing Ext.data.Model instance. If the next step was creating a record, just by doing formPanel.getForm().reset() will still keep the old _record reference in memory, thus updateRecord() will try to write over the last record used. reset method should ideally delete the _record reference, and updateMethod should exit gracefully if no record is supplied.
- Not sure if this is a feature request or a bug. The whole idea is lessening the amount of code on the app side and keeping the logic within the framework
Possible fix:
Code:// Ext.form.Basic reset: function() { Ext.suspendLayouts(); var me = this, fields = me.getFields().items, f, fLen = fields.length; for (f = 0; f < fLen; f++) { fields[f].reset(); } // delete reference to me._record if it exists delete me._record; Ext.resumeLayouts(true); return me; }, updateRecord: function(record) { record = record || this._record; // just exit gracefully if record does not exist if (!record) { return false; } var fields = record.fields.items, values = this.getFieldValues(), obj = {}, i = 0, len = fields.length, name; for (; i < len; ++i) { name = fields[i].name; if (values.hasOwnProperty(name)) { obj[name] = values[name]; } } record.beginEdit(); record.set(obj); record.endEdit(); return this; },Grgur Grisogono
Ext JS in Action SE co-author
Exercising awesomeness at Modus Create - Official Sencha Partner
Get in touch for Sencha Touch Training
@ggrgur
-
18 Jul 2012 3:01 PM #2
Thanks for the great bug report! Fixed for 4.1.2
Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-6595
in
4.1.




Reply With Quote