View Full Version : Write event for Ext.data.Store

2 Nov 2010, 8:01 AM
Hello to all,

I have a Store with a write event listener like this:
var jsWriter = new Ext.data.JsonWriter({
returnJson: true,
writeAllFields: true

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

var store = new Ext.data.Store({
docID: docID
storeId: 'id',
proxy: proxy,
reader: jsReader,
writer: jsWriter,
remoteSort: false,
sortInfo: {
field: 'sortOrder',
direction: 'ASC'
autoSave: false,
listeners: {

write: {
fn: function( store, action, result, res, rs ){

The reader is configured from the server with the metaData element in the server response.
When I have an update action I want to read the data returned from the server.
This works ok when I change only one record.

For example I do rs.get('id') and it works fine.
But my problem starts when I change more than one records.
I see that the client sends 2 for example.
The server returns the correct 2 records back to the client but inside the write listener the rs.length is 0 !

Why is that ?

Possibly this means that the client was not able to parse the answer form the server ?

Why not undefined then ?

Thank you in advance

3 Nov 2010, 7:04 AM
That's still something that has to be fixed.

During processing, Ext removes each element from the 'rs' array.

The fact that you see an empty array actually means all records were processed correctly.

3 Nov 2010, 7:10 AM
Hello Condor,

I almost forgot to update this thread.
I imagined that :)

I have found a workaround in the meantime that works ok.

I have made a private variable and I keep the getModifiedRecords() of the store.
When the time comes that I want to process the records I access that variable instead of the rs.

Additionally I have found that the records coming back from the server inside the server's response must have the same exact order as the client transmitted, otherwise the store changes positions of the records. This could produce several problems if you expect to find something specific always at position 1, 2, etc...

Thank you again