Extjs 如何在store.sync()之后更新所有属性?
在sync()更新后,只更新更改的一行,而不是响应中的所有行 型号:Extjs 如何在store.sync()之后更新所有属性?,extjs,extjs4.1,Extjs,Extjs4.1,在sync()更新后,只更新更改的一行,而不是响应中的所有行 型号: Ext.define('Exp.model.ProfileChannel', { extend: 'Ext.data.Model', fields: ['id', 'channel', 'server', 'profile'], proxy: { type: 'ajax', api: { read: '/profilechannel/list',
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: ''
}
{
id: '1',
profile: 'profile id',
channel: 'channel id',
server: ''
}
之后:record.set('channel','channelid')代码>
响应:
{
"success":true,
"data":[
{
id: '1',
profile: 'profile id',
channel: 'channel id',
server: 'server id added on backend'
}
]
}
最后我有了这样的记录:
{
id: '1',
profile: 'profile id',
channel: '',
server: ''
}
{
id: '1',
profile: 'profile id',
channel: 'channel id',
server: ''
}
因此,问题是我如何更新服务器值,我有了新的值作为响应。。那是虫子吗?还是我做错了?如果extjs忽略了所有属性,为什么我要放置它们?它的行为应该完全符合您的预期。更新过程后从存储返回的所有记录都应替换存储中可能已有的本地副本。您可能需要检查ExtJs代码并对其进行调试,以查看出了什么问题
我肯定使用与ExtJS4.0.7相同的逻辑。可能是4.1版出现了问题,或者您需要调整存储/代理中的某些配置。我也遇到了一些问题,记录没有在4.1版更新。经过一些调试,我发现所有extjs模型字段都需要在服务器响应中返回
extjs没有抛出任何错误,只有store.sync()和record.save()上的失败回调抛出错误。很难找到……绝对。100%. 但话说回来,在我的项目中,它一开始不起作用。我必须跟踪我的读卡器未正确配置的问题。一旦响应中的记录被正确解析,所有内容都会变得非常闪亮和美好,只需使用4.0.7进行测试,它就可以工作,因此这是一个bug或某些更改。如果是bug,你可以将其发布在Sencha论坛上,他们会修复它。但是他们确实改变了4.1中的很多东西-也许它的工作原理有些不同-你可能想弄清楚问题到底出在哪里。你是如何克服的?此处可能重复: