我有以下使用代理通过AJAX从URL检索JSON的模型。
Ext.define('RateManagement.model.Currency', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'code', type: 'string' }
],
proxy: {
type: 'ajax',
url: 'currencies.json'
}
});
如何更改此选项以使用静态硬编码值而非数据库驱动值?
我一直在查看文档http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.data.Model,但我遇到了Raw
,但我不确定如何使用它,或者如果它是正确的属性。
答案 0 :(得分:1)
类似的东西:
var store = new Ext.data.Store({
model: 'RateManagement.model.Currency',
data: [{
id: 1,
name: 'Foo',
code: 'abc'
}]
});
答案 1 :(得分:1)
您可以为模型使用memory proxy:
Ext.define('RateManagement.model.Currency', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'code', type: 'string' }
],
proxy: {
type: 'memory',
reader: 'json',
data: [
{id: 1, name: 'Foo', code: 'foo'},
{id: 2, name: 'Bar', code: 'bar'},
{id: 3, name: 'Baz', code: 'baz'}
]
}
});