vendredi 28 mars 2014

ExtJs: How to read GUID from server on insert into store via proxy


Vote count:

0




As per http://ift.tt/1mbijw5 example, I have the following code on my grid to facilitate adding new records to my store:



tbar: [{
text: 'Add Rate',
handler: function(button) {
var myGrid = button.up('grid');
//console.log(myGrid);
var myPlugin = myGrid.getPlugin('rowediting');
myPlugin.cancelEdit();

var r = Ext.create('RateManagement.model.CountrySpecific', {
id: '',
hostCountryId: '',
hostCountry: '',
rate: 0,
currencyId: '',
rateTypeId: '',
frequencyCode: '',
perFamilyMember: '',
familySize: 0
});

console.log(r);

var store = myGrid.getStore();

store.insert(0, r);
myPlugin.startEdit(0, 0);
}
}],


This is my model with the proxy:



Ext.define('RateManagement.model.CountrySpecific', {
extend: 'Ext.data.Model',
fields:
[
{name:'id', type: 'string'},
{name:'hostCountryId', type: 'string'},
{name:'hostCountry', type: 'string'},
{name:'rate',type: 'number', useNull: true},
{name:'currencyId', type: 'string'},
{name:'rateTypeId', type:'string'},
{name:'frequencyCode', type:'string'},
{name:'perFamilyMember'},
{name:'familySize', type: 'int', useNull: true}
],
proxy: {
type: 'rest',
format: 'json',
url: '/intake/sap/rates/CountrySpecific',
actionMethods: {
create : 'PUT',
read : 'GET',
update : 'PUT',
destroy: 'PUT'
}
}
});


Whenever I click "Add Rate" to insert a new record into my store, it calls my proxy and generates a GUID. However, when I go to click "Update" on that record, there is no ID value - it's just null.


So, is there a way to use the reader of the proxy to try to update my model with the new ID that was generated?


Or, am I going about this the wrong way?



asked 54 secs ago






Aucun commentaire:

Enregistrer un commentaire