PDA

View Full Version : Proxy update not called on model record.set



netlinxman
13 Jun 2013, 11:38 AM
I have a form that i use to either Save a new record or Update a record to a store. When i open the form w/o values to add a new entry, it correctly fires the CREATE operation of my CRUD API that is associated with a JSON proxy. When I select an item from a grid and populate it to the same form for modification - everything is properly defined in the form. When I make a change to one or more fields in the form, and save, it is failing to call the UPDATE operation of my CRUD. I've attached a listener to the UPDATE call, and nothing is firing, and there's no network call to my server from the proxy.

What is the next step in troubleshooting this? I have had this working before, and something changed, but that is beside the point. I want to know where to turn next? My code for the "Save" button is as follows:


var form = button.up('form').getForm(); // get the basic form
if (form.isValid()) { // make sure the form contains valid data before submitting
var properties = form.getValues();
var store = Ext.getStore('Properties');


// check to see when we're creating vs updating
if(properties.id === "") {
properties.phantom = true;
store.add(properties);
} else {
// http://stackoverflow.com/questions/11835729/how-do-i-submit-a-form-using-a-store-under-extjs
var record = form.getRecord();
console.log(record);
record.set(properties);
console.log(record);
}
button.up('window').close();
} else { // display error alert if the data is invalid
Ext.Msg.alert('Invalid Data', 'Please correct form errors.');
}


I get correct output in my console.log calls. The grid doesn't refresh w/ the new value && I do not get a proxy call.

Can you please suggest my next step in trying to figure this out? I'm thinking perhaps it is the record.set(properties) call to the model that i'll need to investigate, I'm just not sure how.

Thanks

slemmon
16 Jun 2013, 9:59 PM
Try doing record.commit() after record.set().
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Model-method-commit

netlinxman
17 Jun 2013, 5:14 AM
Slemmon,

Yes, I had tried that as well. No Joy. I've since fixed this issue, and i can't even recall my fix. I was more interested in how one would go about trying to figure out how to test, debug, isolate and identify the culprit when this happens. I was clearly calling something that was failing, and i'm thinking there's an event i could get error message output from... Just not sure which. Model? Store? and how to add it... I think i had an event handler on my proxy, but of course i wasn't seeing anything - because it wasn't firing.