PDA

View Full Version : Data: Problem defining proxy in store



jmclem
19 Apr 2011, 6:36 AM
Hi,

when I create a model and a store, I would prefer defining the proxy in the store. However, the code below does not work: I get an error on the JS console (
Uncaught Error: You are using a ServerProxy but have not supplied it with a url. on save() ):



Ext.regModel( "person", {
fields: [
{ name: "id", type:"string" },
{ name: "last_name", type: "string" },
{ name: "first_name", type: "string" }
]
});

Ext.regStore({
model: "person",
storeId: "person_store",
proxy: {
type: "localstorage",
id:"com.example.test"
}
});

// somewhere else ...

var person_rec = Ext.getStore("person_store").create({
id:new Date().getTime(),
last_name:"Duck",
first_name:"Donald"
});

person_rec.save();



When I have a look at the implied objects, the Ext.data.Model calls getProxy(), which returns this.constructor.proxy, i.e. not the one set in the store. I would have expected the .create() to have set the proxy properly.

Is my understanding wrong? Is the way I use all of this correct?

Thanks,

Jean-Marie.