PDA

View Full Version : Ext.Direct / Ext.Grid -- idProperty is being passed back as undefined



poopsmith
17 Feb 2010, 5:11 PM
This is the store:



store: new Ext.data.DirectStore({
storeId: 'registrant-activity-grid',
autoDestroy: true,
autoLoad: true,
baseParams: {personalId: this.personalId},
idProperty: 'activityId',
autoSave: true,
writer: new Ext.data.JsonWriter({
encode: false,
encodeDelete: false,
writeAllFields: true
}),
api : {
read : Direct.Registrant.getActivities,
create : Direct.Echo.send,
destroy : Direct.Registrant.deleteActivity,
update : Direct.Echo.send
},
fields: [
{name: 'activityId', type: 'int'},
{name: 'activityType'},
{name: 'activityDetails'},
{name: 'notes'},
{name: 'activityDate', type: 'date'},
{name: 'personalId'},
{name: 'projectId'},
{name: 'isComplete'}
]
}),


This store is backing a GridPanel.

The load works correctly, this is the POST request that the client sends to the server:


{"action":"Registrant","method":"getActivities","data":[{"personalId":"20"}],"type":"rpc","tid":3}

HOWEVER, I am trying to delete a row, and this is what is being POST back to the server:


{"action":"Registrant","method":"deleteActivity","data":[{"personalId":"20","undefined":"1"}],"type":"rpc","tid":4}

My question is, why does the data being sent back to the server have a key of "undefined" instead of activityId ?

And an edit: if I change encodeDelete from false to true, this is the data that ends up being posted:


{"action":"Registrant","method":"deleteActivity","data":[{"personalId":"20","undefined":{"activityId":"1"}}],"type":"rpc","tid":4}

ishobr
18 Feb 2010, 12:11 AM
Add 'root' config option to your data store, because default 'root' value is undefined.

I always use:





new Ext.data.DirectStore({
...: ...,
root: 'data',
...: ...
})

...
...

poopsmith
18 Feb 2010, 9:28 AM
Thanks, got it.