PDA

View Full Version : Need some expert eyes



Mango_lier
19 Mar 2010, 12:03 PM
Below is a typical FormPanel extension class. I need to get to the returned eval'ed JSON response. I implemented an interceptor on the setValue() but how do I get to the "this.result". Any idea where it is hidden.


Ext.namespace('myProject4');
myProject4.recUserInfoRecord = Ext.extend(Ext.FormPanel, {
frame: true,
title: 'Some title',
....
},
constructor: function(config) {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

var Name = new Ext.form.TextField({
emptyText: "Please enter Name",
fieldLabel: "Name",
name: "Name",
allowBlank: true,
maxLength: 50,
anchor: "95%"
});
var Address = new Ext.form.TextField({
emptyText: "Please enter Address",
fieldLabel: "Address",
name: "Address",
allowBlank: true,
maxLength: 50,
anchor: "95%"
});
config = Ext.apply({
items: [Name, Address],
buttons: [{
text: 'Add',
scope: this,
handler: function() {
....
}
},{
text: 'Update',
scope: this,
handler: function() {
.....
this.load({
method: 'GET',
url: 'data.php',
waitMsg: 'Loading...'
});
.....
}
},{
text: 'Delete',
scope: this,
handler: function() {
....
}
}]
});

myProject4.recUserInfoRecord.superclass.constructor.call(this, config);

this.getForm().waitMsgTarget = this.id;
this.getForm().setValues = this.getForm().setValues.createInterceptor(function(o) {
this.getForm().items.each(function(c) {
==> This is where I need to get to the eval'ed JSON data which has additional
==> Info I need to process the form. Where is the "result" hiding
},
this);
},
this);
}
});

Animal
19 Mar 2010, 11:28 PM
It's gone. By the time you are setValules, you just have the data property.

You need to get in to the Ext.form.Action.Load stage.

I know it's a common requirement to preprocess loaded data, so I have had a Feature Request outstanding for YEARS to add more events:



Ext.override(Ext.form.Action.Load, {
success : function(response){
var result = this.processResponse(response);
if(result === true || !result.success || !result.data){
this.failureType = Ext.form.Action.LOAD_FAILURE;
this.form.afterAction(this, false);
return;
}
if (this.form.fireEvent('beforeactioncomplete', this.form, result) !== false) {
this.form.clearInvalid();
this.form.setValues(result.data);
this.form.afterAction(this, true);
}
}
});


Fires "beforeactioncomplete" through your BasicForm passing the full result object.

Become a Premium Member and add your voice to the Feature Request!

To me it's so obvious that logic might need injecting at this point! They don't think so.

Mango_lier
20 Mar 2010, 2:00 PM
Thanks for the reply, I got around the issue by embedding the extradata within the data. That way simple interceptor will do the trick.

However I think 'beforeactioncomplete' is required, as post processing is sometimes needed before setting the values.

As far as adding voice to the feature request is concerned, if Ext folks are not listening to you then my $500 will not do the trick. But I am considering becoming a paid member