View Full Version : updateRecord calls convert?

23 Apr 2013, 3:30 PM
I'm using ExtJS 4.1.1a and calling form.loadRecord() to push a model to my form. When the user clicks an OK button, I validate the form and then call form.getForm().updateRecord(). Unfortunately, updateRecord winds up invoking any convert functions which I've defined on my model. This seems very unintuitive.

For example, let's say I've defined a field called frequency that is measured in hertz but displayed in megahertz:

fields: [
name: 'frequency',
type: 'float',
convert: function (v, rec)
return v / 1000000; // convert Hz to MHz

When I load up my model, the server value is correctly converted from Hz to MHz. Upon calling loadRecord, the form is populated with a value in MHz. The user then edits the value (in MHz) and presses OK. I call updateRecord which again invokes the convert function.

1) How can I prevent updateRecord from calling the conversion function (since the value is already in the correct units)?
2) How do I send a value in Hz back to my server? There's no "convertBack" config that a reader that would hook into.

25 Apr 2013, 9:43 AM
The model's convert function won't now that the values supplied to it are pre-converted by your server. You'll need to inform it in the convert function whether it's to proceed with the convert or just return the value itself.