我在数据模式中注册了id和名称空间,之后关联停止了工作。如何解决?
// Fiddle.model.User
schema: {
id: 'fiddle',
namespace: "Fiddle.model",
...
小提琴:https://fiddle.sencha.com/#view/editor&fiddle/22pc
这是错误消息: VM775 app.js:13 Uncaught TypeError:user.setAddress不是函数
答案 0 :(得分:0)
您需要在一个模型中添加名称空间和ID并扩展该模型。 小提琴:https://fiddle.sencha.com/#view/editor&fiddle/22rm
Ext.define('Fiddle.model.Address', {
extend: 'Ext.data.Model',
schema: {
// I registered the id and namespace in the data schema and after
// that the releationships stopped working.
id: 'fiddle',
namespace: "Fiddle.model",
proxy: {
type: 'ajax',
url: 'Users.json',
reader: {
rootProperty: 'result.ResultItems'
}
}
},
fields: [{
name: 'street',
type: 'string'
}]
});
Ext.define('Fiddle.model.User', {
extend: 'Fiddle.model.Address',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}],
hasOne: {
role: 'address',
association: "MassOperationTypeBySendMassNotificationsRequest",
type: 'Fiddle.model.Address',
reader: {
rootProperty: 'address'
},
inverse: { role: "sendMassNotificationsRequest" }
},
hasMany: [{
type: 'Fiddle.model.Order',
role: 'orderList',
reader: {
rootProperty: 'OrderList'
},
inverse: {
role: 'user'
}
}]
});