PDA

View Full Version : Update Store with form values



TampaBay55
6 Jan 2012, 7:05 AM
Greetings:

As I am fairly new to Ext JS, I have run into a wall and I cannot seem to find the answer. I would like to appeal to someone in the community to give me a push in the right direction. I have a form that I call with the following code:


updateRecord: function(button){
var store = this.getUsrDataStoreStore();
var grid=button.up('usrdatabrowse');
var record = grid.getSelectionModel().getLastSelected();
var view = Ext.widget('usrdataform');
view.down('form').loadRecord(record);
},


The form loads fine and displays the necessary data. On the save the record store is not being updated or the store sync being called. Essentially, the record is not being updated. I am using the following code on a "Save" button click:


saveRecord: function(button){
var store = this.getUsrDataStoreStore();
var win = button.up('window');
var form = win.down('form');
values = form.getValues();
store.getById(values['recordid']).set(values);
}


Now I realize the call to store.set is incorrect as the parameter "values" is not a proper parameter. I need some direction on the methods to save this record. Thanks for any help.

TampaBay55
6 Jan 2012, 8:36 AM
UPDATE:

I was able to fix this issue with the following code:


saveRecord: function(button){
var win = button.up('window');
var form = win.down('form');
var record = form.getRecord();
record.set(form.getValues());
this.getUsrDataStoreStore().update(record);
}


Just want to confirm that this is the proper method for updating a record from a form. Thanks.