PDA

View Full Version : url undefined when using Ext.data.Model



Rothariger
31 Jul 2012, 6:46 AM
Hi,

i'm working in a small project and i want to use the ext.data.model, the thing is that i having some problems when i want to load some data.


here is the model declaration.



Ext.define('Model.Item',{
extend: 'Ext.data.Model',
fields: ['id', 'code', 'description'],


proxy: {
type: 'ajax',
api: {
read: 'Handlers/Item.ashx',
create: 'Handlers/Item.ashx?action=create',
destroy: 'Handlers/Item.ashx?action=delete',
update: 'Handlers/Item.ashx?action=update'
},
reader: {
type: 'json',
root: 'items'
},
writer: {
type: 'json',
writeAllFields: true,
root: 'data',
allowSingle: false
}
}
});


and i using it with a jsonstore like this.



new Ext.data.JsonStore({
storeId: 'mainStore',
autoLoad: true,
model: 'Model.Item'
})


binging it with a grid, before i wasnt using model, and was working just fine. no i cant get it to work.

i get an exception in ext-all.js



urlAppend : function(url, string) {
if (!Ext.isEmpty(string)) {
return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
}


return url;
},


this funcion is called from Ext.data.proxy.Server in the buildUrl function.


well any help would be appreciated.

Rothariger
31 Jul 2012, 10:24 AM
debugging the code i can see that the store doesnt use the api of the model at all...

is there a workaround for this?

mankz
31 Jul 2012, 10:33 AM
Can you post a complete test case?

Rothariger
31 Jul 2012, 11:16 AM
Fixed.

using a Ext.data.Store made the trick!