PDA

View Full Version : Ext.data.Store



pouli
7 Oct 2010, 3:12 AM
Hello to all,

my store initiates a create action although I have made an udpate.
Why ? Do I have to specify something else as well ?

Here is the code:

var jsWriter = new Ext.data.JsonWriter({
returnJson: true,
writeAllFields: true
});

var jsReader = new Ext.data.JsonReader();

var proxy = new Ext.data.HttpProxy({
api:{
read : '/ajax/remote?doAction=AJAX_loadAdditionalRemark',
create : '/ajax/remote?doAction=AJAX_saveAdditionalRemark',
update : 'app.php/settings/update', // Not needed yet
destroy : 'app.php/settings/destroy' // Not needed yet
}
});


var store = new Ext.data.Store({
baseParams:
{
docID: docID
},
id: 'setting',
proxy: proxy,
reader: jsReader,
writer: jsWriter,
autoSave: false,
listeners: {
load: {
fn: function(store, records, options)
{
// testing
var tn = document.getElementById('totalNumOfEULans').value;
for( i = 1; i <= tn; i++ )
{
Ext.getCmp('txtField' + i).setValue(store.getAt(0).data.text);
}
}
}
}

});


store.load();


....

Inside a button listener I do this:

var urec = store.getAt(0);
urec.set('text', 'New text set by the button');

var tn = document.getElementById('totalNumOfLans').value;
for( i = 1; i <= tn; i++ )
{
Ext.getCmp('txtField' + i).setValue(store.getAt(0).data.text);
}

alert('UI updated');

store.save();
alert('store save');

At this point I would expect to receive an update event. On the contrary a create event is being generated.

Thank you in advance

Condor
7 Oct 2010, 3:53 AM
1. Store 'id' is deprecated. Use 'storeId' instead.
2. You are using metaData to configure the reader? Are you setting the correct idProperty?

pouli
7 Oct 2010, 5:11 AM
Condor you are correct once again. :)