PDA

View Full Version : XmlStore always uses POST instead of PUT to update records



MrRob
3 Jan 2010, 5:52 PM
Hello ExtJS Users,

I am trying to use ExtJS with a rails backend. I want to use a Grid to display the data in the rails database and update it via rest. I can get the data successfully from rails and I can also create new entries as well. However when I attempt to update the store always attempts to use POST instead of PUT to update the record. This creates duplicate records. Any help that can be provided would be great.



var writer = new Ext.data.XmlWriter({
encode:false,
});

var store = new Ext.data.XmlStore({
restful: true,
url:'/entries.xml',
writer: writer,
autoSave:true,
autoLoad:true,
autoDestroy:true,
storeId:'myStore',
record: 'entry',
fields: ['id',
'answer',
'question',
{name:'categoryId',
type:'integer'}
]
});

zachext
3 Jan 2010, 9:35 PM
Try adding an idProperty to your XmlStore. If it is not defined, the records are read into the store as phantoms. Saving a phantom record calls the create / POST restAction rather than than update / PUT.



var writer = new Ext.data.XmlWriter({
encode:false,
});

var store = new Ext.data.XmlStore({
restful: true,
url:'/entries.xml',
writer: writer,
autoSave:true,
autoLoad:true,
autoDestroy:true,
storeId:'myStore',
record: 'entry',
idProperty:'id',
fields: ['id',
'answer',
'question',
{name:'categoryId',
type:'integer'}
]
});

MrRob
3 Jan 2010, 11:17 PM
Thanks for your help! Its always the small things that you miss!