Quick question about the form loading in the auto code example programs.
The auto-code applications use an Ajax request, and loads the data into the form in the success callback using form.setValues().
There's also a call to the encodeProperties function that's doing something with response.root:
I was thinking about using the form.load() to do this instead; it seems simpler to me this way:
Before I change how the forms are loaded I was wondering:
1) What is the encodeProperties doing?
2) Is there a compelling reason to use this approach over using form.load()?
Here's the encodeProperties function which has been added to the Application object (I don't understand what it's purpose is):
The auto-code applications use an Ajax request, and loads the data into the form in the success callback using form.setValues().
There's also a call to the encodeProperties function that's doing something with response.root:
Code:
Ext.Ajax.request({ url: '/valence/vvcall.pgm', params: { pgm: 'AC1021', action: 'getRec', VVRRN: VVRRN }, success: function(response) { var r = Ext.decode(response.responseText); r.rec = app.encodeProperties(r.rec); if (r.success) { windowform.setValues(r.rec); } else { Valence.util.Helper.msg('Error', 'Could not load record'); } } });
I was thinking about using the form.load() to do this instead; it seems simpler to me this way:
Code:
form.load({ url: '/valence/vvcall.pgm', params: { pgm: 'AC1021', action: 'getRec', VVRRN: VVRRN }, });
1) What is the encodeProperties doing?
2) Is there a compelling reason to use this approach over using form.load()?
Here's the encodeProperties function which has been added to the Application object (I don't understand what it's purpose is):
Code:
encodeProperties: function(obj) { var mapObj = { "#":"p", "$":"s", "@":"a" }; Ext.Object.each(obj,function(prop,val){ text = prop; text = text.replace(/#|\$|@/g, function(matched){ return mapObj[matched]; }); if (text !== prop){ delete obj[prop]; obj[text] = val; } }); return obj; },
Comment