PDA

View Full Version : can't get jsonstore to trigger a write event



jprosser
21 Jul 2010, 4:34 AM
Hi Folks,
I've been staring at this for hours and not seeing it, Could someone else try?


Here's the JSON response seen with the 200 via firebug

{
"success" : true,
"id" : "105"
}


Here is the code



var gridProxy = new Ext.data.HttpProxy({
api: {
read : '/listdata/read'
,create : '/listdata/create'
,update : '/listdata/save'
,destroy: '/listdata/delete'
}

,listeners: {
write : function(t,action,data,resp,rs,opts){
console.log('data write event');
}
}


});

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

var gridRecordFactory = Ext.data.Record.create([
{name: 'name' , type: 'string'},{name:'id', type: 'string'},{name:'form_id', type: 'string'}
);

var lvStore = new Ext.data.JsonStore({
autoDestroy: true
,storeId: 'gridstore'
,autoSave : true
,totalProperty: 'results'
,waitMsg:'Loading Data...'
,messageProperty : 'message'
,successProperty: 'success'
,idProperty: 'id'
,root : 'data'
,listeners: {
write : function(store,action,result,res,rs){
console.log('write event');
}
,add : function(t,r,i){
console.log('add event');
}
,save : function(s,b,d){
console.log('save event');
}
,update : function(t,r,o){
console.log('update event');
}
}
,proxy: gridProxy
,paramNames : {
start : 'start', // The parameter name which specifies the start row
limit : 'limit', // The parameter name which specifies number of rows to return
sort : 'sort', // The parameter name which specifies the column to sort on
dir : 'dir' // The parameter name which specifies the sort direction
}
,recordFactory: gridRecordFactory
,writer: gridWriter
,fields: ['name','id','form_id'}
});





Here is how it get's called:




var blank = new lvStore.recordFactory({name:'newnewnew',form_id: form_id});

lvStore.add([blank]);