在sync((之后,只更新了一行,但不是全部来自响应。
型:
Ext.define('Exp.model.ProfileChannel', {
extend: 'Ext.data.Model',
fields: ['id', 'channel', 'server', 'profile'],
proxy: {
type: 'ajax',
api: {
read: '/profilechannel/list',
update: '/profilechannel/save'
},
reader: {
type: 'json',
root: 'data'
}
}
});
商店:
Ext.define('Exp.store.ProfileChannels', {
extend: 'Ext.data.Store',
model: 'Exp.model.ProfileChannel',
autoSync: true
});
假设在商店里我有这样的记录:
{
id: '1',
profile: 'profile id',
channel: '',
server: ''
}
然后之后:record.set('channel', 'channel id');
回应:
{
"success":true,
"data":[
{
id: '1',
profile: 'profile id',
channel: 'channel id',
server: 'server id added on backend'
}
]
}
最后我有这样的记录:
{
id: '1',
profile: 'profile id',
channel: 'channel id',
server: ''
}
所以问题是我如何更新和服务器价值我有新的值作为响应.. 这是一个错误吗? 还是我做错了? 如果 extjs 忽略它们,我为什么要放置所有属性?
它的行为应该完全符合您的预期。更新过程后从存储返回的所有记录都应替换存储中可能已有的本地副本。您可能需要检查 ExtJs 代码并对其进行调试以查看出了什么问题。
我绝对对 ExtJs 4.0.7 使用相同的逻辑。可能是某些东西在 4.1 中被破坏了,或者您可能需要调整商店/代理中的一些配置。
我还有一些问题,即记录在 4.1 上没有更新。 经过一些调试,我发现所有 extjs 模型字段都需要在服务器响应中返回!
extjs 没有抛出任何错误,只有 store.sync(( 和 record.save(( 上的失败回调给我抛出了一个错误。 很难找到...