PDA

View Full Version : DirectStore sync after add record



el.weilando
26 Jun 2011, 9:26 AM
REQUIRED INFORMATION

Ext version tested:


Ext 4 rev 0.2



Browser versions tested against:


FF3 (firebug 1.3.0.10 installed)
Safari 4



Description:


When I add a record to Ext.data.DirectStore, the store doesn't sync with the server. add event is indeed fireing, but
store.getNewRecords() is empty.

should getNewRecords() have the new records until proxs has complet the update with server?

this is also when store is created as Ext.data.Store and has an Direct.Proxy configurtion



Steps to reproduce the problem:


foo
bar



The result that was expected:


foo
bar



The result that occurs instead:


foo
bar



Test Case:



<<insert working code to reproduce the report >>






Operating System:


OSX

mitchellsimoens
26 Jun 2011, 9:45 AM
This is working for me:


var grid = Ext.create('Ext.grid.Panel', {
store: {
model: 'Company',
remoteSort: true,
// autoLoad: true,
sorters: [{
property: 'name',
direction: 'ASC'
}],
proxy: {
type: 'direct',
directFn: TestAction.getGrid
}
},
columns: [{
dataIndex: 'name',
flex: 1,
text: 'Name'
}, {
dataIndex: 'turnover',
align: 'right',
width: 120,
text: 'Turnover pa.',
renderer: Ext.util.Format.usMoney
}],
height: 350,
width: 600,
title: 'Company Grid',
renderTo: Ext.getBody()
});

setTimeout(function() {
var store = grid.getStore();

store.on('add', function() {
console.log(store.getNewRecords());
});

store.add({
name : 'Test',
turnover : 5
});
}, 2000);

getNewRecords returns an Array with one Model instance in it.

el.weilando
26 Jun 2011, 10:19 AM
hm... weird...

this is my code



this.fileStore = Ext.create('Ext.data.DirectStore', {
autoSync: true,
model: 'ip.docmanager.fileModel',
paramsAsHash: true,
api: {
create : ip.docmanager.api.RPCAction.createFileNode,
read : ip.docmanager.api.RPCAction.getFileNodes,
update : ip.docmanager.api.RPCAction.updateFileNode,
destroy : ip.docmanager.api.RPCAction.destoryFileNodes
},

listeners:{
add:{
fn: function(store){

console.log(store.getNewRecords());
console.log(store.getUpdatedRecords());
console.log(store.getRemovedRecords());
console.log(store.data);


},
scope:this
}
}
});

Button to add records


handler : function() {
var id = Ext.id();
var user = Ext.create('ip.docmanager.fileModel', {
id : Ext.id(),
type : "24",
name: "blablablabla"
});

this.fileStore.add(user);

Add-Event is fired, but in console i get 3 empty arrays. in store.data in console.log, I can find the new record.