PDA

View Full Version : Treestore Update not called when modifying a record



CiaranT
19 Jun 2012, 11:32 PM
Hi there,

I want to modify the details of a treestore record and send the 'Update' to the DLL specified in my API.

The record is updated in the tree, but no call is made to the DLL.

This is the code i am using to update the record.



var rec = store.getNodeById(sAssetID);
rec.beginEdit();
rec.set('Asset_ID', sAssetID);
rec.set('Name', sName);
rec.set('text', sName);
rec.phantom = false;
rec.endEdit();
rec.commit();

// Sync the changes
store.sync({
scope: this,
success: function () {
console.log("SUCCESS sync");


},
failure: function () {
console.log("FAILED sync");
}
});


Treestore proxy



proxy: {
type: 'ajax',
api: {
create: 'http://localhost/a.dll/asset?method=Create',
read: 'http://localhost/a.dll/asset?method=Read',
update: 'http://localhost/a.dll/asset?method=Update',
destroy: 'http://localhost/a.dll/asset?method=Delete'
},
url: 'http://localhost/a.dll/asset',
reader: {
type: 'json',
root: 'Assets'
},
writer: {
type: 'json'
}
}













The datamodel:



Ext.define('App.model.dmAsset', {
extend: 'Ext.data.Model',
idProperty: 'Asset_ID',
fields: [
{
mapping: 'Asset_ID',
name: 'Asset_ID',
type: 'string'
},
{
mapping: 'Name',
name: 'Name',
type: 'string'
}
/snip
]
});











Any ideas why the Update is not getting called? Thank you :)

CiaranT
21 Jun 2012, 4:38 PM
Anyone know about updating data in a treestore? :-/

scottmartin
22 Jun 2012, 12:31 PM
Sync updates any changed records, but you are setting phantom and calling commit.

Scott.

CiaranT
23 Jun 2012, 9:31 PM
Thanks again Scott. That fixed my issue.. Including removing setting the primary ID.



var rec = store.getNodeById(sAssetID);
rec.beginEdit();
rec.set('Name', sName);
rec.set('text', sName);
rec.set('Description', sDescription);
rec.endEdit();


store.sync();