0
我正在一個小型項目中工作,我想使用ext.data.model,事情是當我想加載一些數據時遇到一些問題。使用Ext.data.Model時未定義的URL
這裏是模型聲明。
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
}
}
});
和我用它與這樣的jsonstore。
new Ext.data.JsonStore({
storeId: 'mainStore',
autoLoad: true,
model: 'Model.Item'
})
在網格之前,我沒有使用模型,並且工作得很好。不,我不能讓它工作。
我得到的網址是EXT-all.js
urlAppend : function(url, string) {
if (!Ext.isEmpty(string)) {
return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
}
return url;
},
這funcion從Ext.data.proxy.Server在buildUrl函數調用未定義例外。
以及任何幫助,將不勝感激。
可能通過使用JsonStore來重寫模型的代理定義JsonStore添加了自己的代理配置,如果存在這種配置,它將不會在模型中尋找它。嘗試用'Ext.data.Store'替換'Ext.data.JsonStore'。 – Izhaki 2012-07-31 16:44:32
我還沒有在jsonstore中聲明代理。但調試EXTJS我發現商店加載爲this.proxy.read(xxx),而不是搜索me.model.proxy(如果存在)... – Rothariger 2012-07-31 18:25:54
如果我理解你正確的話,是的 - JsonStore自動添加一個代理,其中被稱爲而不是模型。那麼你的問題解決了嗎? – Izhaki 2012-07-31 18:29:36