View Full Version : Form Load Action Incorrect?
thejoker101
10 Apr 2007, 1:45 PM
On success, it (through several functions) evals the response text, but then it will (I assume) incorrectly use the result (the commented out parts).
success : function(response){
var result = this.processResponse(response);
if(result === true || !result /*!result.success || !result.data*/){
this.failureType = Ext.form.Action.LOAD_FAILURE;
this.form.afterAction(this, false);
return;
}
this.form.clearInvalid();
this.form.setValues(result/*.data*/);
this.form.afterAction(this, true);
}Success won't exist and neither will data since result IS the data. My responseText is just a straight encoded table row.
I also notice that in BasicForm.js, the completed action event is going by two different names (actioncomplete in the events array and actioncompleted in the fireEvents).
Lastly, should the combobox on load do a query and set the corresponding displayField? Some of mine just look odd with the loaded value in there because they are OpenLDAP distinguished names.
jack.slocum
10 Apr 2007, 1:52 PM
The result from you call should be in the format:
{ success: true/false,
data: {
// field data (this can also be an array of objects)
}
};
If you don't like that format or don't care about returning errors, you are welcome to comment out that code.
thejoker101
10 Apr 2007, 2:40 PM
The result from you call should be in the format:
{ success: true/false,
data: {
// field data (this can also be an array of objects)
}
};If you don't like that format or don't care about returning errors, you are welcome to comment out that code.
Hmm, if our code is supposed to be returning true or false, wouldn't it make sense to give the responseText to our actioncompleted/failed listeners so we can see the response and possibly alert an error that was encoded in the response? I was also thinking whether it would make better sense to make "data" (the root) a configurable option like everywhere else just in case someone is reusing a script somehow and they don't have it stuffed under data. Should success also be in any other JSON loadable response such as datastores? This is the first place I've seen this in your library and it might make it more convenient to say upfront in a load that the result will not be correct.
Any comments about my other questions though? Particularly the value going into the field where I have a displayField set. I can see this being a problem since I have several values that will mean nothing to the user, but are very meaningful in the database.
jack.slocum
10 Apr 2007, 3:35 PM
It is available. All the events fire that Action object, which has various properties about the state of the action including the one you are looking for, result. So:
form.on('actioncomplete', function(form, action){
var type = action.type; // e.g. "load"
var data = action.result; // your full json data pre parsed
});
form.on('actionfailed', function(form, action){
if(action.type == 'submit' &&
action.failureType == Ext.form.Action.SERVER_INVALID){
// server side validation failed
}
});
thejoker101
12 Apr 2007, 5:57 AM
I was thinking about the combobox load issue and perhaps if in addition to value we could pass it a displayValue which would then update the input box.
thejoker101
13 Apr 2007, 4:18 AM
I was thinking about the combobox load issue and perhaps if in addition to value we could pass it a displayValue which would then update the input box.
Any thoughts on this?
jack.slocum
13 Apr 2007, 12:07 PM
You mean in your load pass in both? What you can do is attach additional JSON (annything you want) and attach to the actioncomplete event, grab your value and update it (along with other stuff if you needed to).
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.