Consider this model:
Code:
Ext.regModel('EditableUserList',
{
fields: [
{ name: 'LoginUserId', type: 'string' },
{ name: 'FirstName', type: 'string' },
{ name: 'LastName', type: 'string' },
{ name: 'IsNew', type: 'boolean' },
{ name: 'IsDirty', type: 'boolean' },
{ name: 'IsDeleted', type: 'boolean' }],
proxy:
{
type: 'rest',
url: '/Home/EditableUserListDataPortal/',
reader:
{
type: 'json',
successProperty: 'success'
}
}
});
For right now I am using 'rest'
Now consider this code for me store:
Code:
var storeUsers = new Ext.data.Store({ model: 'EditableUserList' })
function getEditList()
{
storeUsers.load(
{
scope: this,
callback: function (records, operation, success)
{
console.log("Got Editable List");
records[0].set('FirstName', 'Slouch');
records[0].set('LastName', 'Man');
}
});
Now consider my save logic:
Code:
function saveUserList()
{
storeUsers.sync({
scope: this,
callback: function (records, operation, success) {
console.log("Saved Editable List");
}
});
}
My problem is perhaps a confusion or maybe a bug. I am not sure.
So, when I call storeUsers.sync(...) it calls my Web Server's HTTP Post. The entire list goes to the server and I persist what changed, and send down the new list, from within my HTTP Post. Then what happens is odd. The store also calls HTTP Put (right now I don't have one) with just the changed data.
Why is the store calling both my HTTP Post and my HTTP Put? I can see the argument for only sending a list of what changed... But I don't get calling both because the Post is sending my entire list including the changes.
I don't want my server to have two calls. How do I disable either one? Or am I doing something wrong?
My second question is the Sync does not call my call-back... Is this a bug? How in the world could you use a Sync without it (if it's not a bug)? I need to know if the entire operation worked or not!
Thanks again!