mohaaron
9 Jun 2009, 1:57 PM
I am trying to figure out how to get access to the record object of the FormPanel. I use the following code to load the FormPanel from a JsonStore on load. I want to be able to pass the record.id value to the params collection when I submit the form. I can't find any way to do this.
Here is the FormPanel being loaded from the JsonStore.
var jsonStore = new Ext.data.JsonStore({
url: '/Bug/GetBugs',
totalProperty: 'totalRows',
root: 'rows',
id: 'PKId',
fields: [
'PKId',
to many fields to list...
],
listeners: {
load: function(store, records, options) {
try {
var record = store.getAt(0);
var form = Ext.getCmp('mainForm');
if (form)
form.getForm().loadRecord(record);
} catch(err) {
console.log(err);
}
},
loadexception: function(store, options, response, e) {
console.log(e);
}
}
});
Here is the submit function on the FormPanel.
buttons: [{
text: 'Save',
handler: function() {
Ext.getCmp('mainForm').getForm().submit({
url: '/Bugs/Edit', // The REST based url that the data will be saved to.
method: 'POST',
params: { id: '10' },
waitTitle: 'Processing...',
waitMsg: 'Please wait...'
});
}
}]
I would like to pass something like selectedRecord.id in place of the value '10' which is some made of value for testing. Is it possible to get access to the record which is bound to the form?
Here is the FormPanel being loaded from the JsonStore.
var jsonStore = new Ext.data.JsonStore({
url: '/Bug/GetBugs',
totalProperty: 'totalRows',
root: 'rows',
id: 'PKId',
fields: [
'PKId',
to many fields to list...
],
listeners: {
load: function(store, records, options) {
try {
var record = store.getAt(0);
var form = Ext.getCmp('mainForm');
if (form)
form.getForm().loadRecord(record);
} catch(err) {
console.log(err);
}
},
loadexception: function(store, options, response, e) {
console.log(e);
}
}
});
Here is the submit function on the FormPanel.
buttons: [{
text: 'Save',
handler: function() {
Ext.getCmp('mainForm').getForm().submit({
url: '/Bugs/Edit', // The REST based url that the data will be saved to.
method: 'POST',
params: { id: '10' },
waitTitle: 'Processing...',
waitMsg: 'Please wait...'
});
}
}]
I would like to pass something like selectedRecord.id in place of the value '10' which is some made of value for testing. Is it possible to get access to the record which is bound to the form?