PDA

View Full Version : Ext Writer Issue



chalu
26 Jun 2009, 7:34 AM
The examples for the new Ext Writter is great but while experimenting with something I observed that Ext.data.Store.save(); returns "prematurely" in my case.

I have an ArraySore into which I just loaded data using Ext.data.Store.loadData() and I want to write these fresh data to my server using the writter, but it turns out that this does not occur because (as I later discovered from within Ext.data.Store) there were no modified records in the store :


var rs = this.getModifiedRecords();
if(!rs.length){
return true;
}


How can I "force it" to save the new data anyway

chalu
27 Jun 2009, 5:28 AM
I am still having trouble with this, thought it was because I was using store.loadData, but store.load() also did not work, even after changing to a JsonStore.

Then I tried store.add and then store.insert. With all of them, the data gets loaded / added / inserted (the grid even shows the red markers) but my writer will just not write anything.
A call to store.getModifiedRecords() after the addition / insertion of the new records still returns an empty array.

Now I am stuck (I bet you've been once :D), I just want to add / insert / load records into an empty store and then use the new writer feature to send them to the server.



// from within my grid, gets called when a button is clicked
generatePins: function(){
var pinData = [];
var store = this.getStore();
var records = [];
var pinCount = parseInt( Ext.getCmp('pincount').getValue() );
for(var i = 0; i < pinCount; ++i){
var uuid = Math.uuid();
var tokens = uuid.split('-');
var pin = tokens[0] + ' ' + tokens[1] + ' ' + tokens[2];
var serial = tokens[3] + ' ' + tokens[4];

//pinData.push( [pin, serial, uuid] ); // when I tried it with an ArrayStore
records.push( new store.recordType({pin: pin, serial: serial, uuid: uuid}) );
}
store.insert(0, records); // also tried store.add(records);

// when I tried getting the data from the server instead
/*var count = parseInt( Ext.getCmp('pincount').getValue() )
store.load({
params: {pinCount: count}
});*/

// after loaading the data, store.getModifiedRecords() is an empty array.
}


It seems now that 'modified recrods' are actually only 'edited' records, not deleted records (as noted in the JsonStore docs) and not added / inserted records. Any hints.

jriff
27 Jun 2009, 10:37 AM
I have the exact same problem. I am using this store:



var store= new Ext.data.JsonStore({
url: '/dealer_list/dealers'
,writer: writer
,autoSave: true
,restful: true
,remoteSort: true
,sortInfo: {
field: "fieldName",
direction: "ASC"
}
,listeners: {
write : function(store, action, result, response, rs) {
App.setAlert(response.success, response.message);
}
}
})


When doing
this.store.remove(record); the grid is updated but this.getModifiedRecords() is en empty array - and ofcourse the save method does nothing.

Anyone?

MattJennings
7 Aug 2009, 1:25 PM
Set record.phantom=true Otherwise the store believes the record already exists on the server side

lpastor
8 Aug 2009, 5:36 PM
Hello Mattjennings, where to put : Set record.phantom=true ?

Would you watch this? http://extjs.com/forum/showthread.php?p=370896#post370896

I have perhaps the same problem ?

Laurent