诀窍在于,存储读取器需要指定 idProperty,否则所有行都被视为新行。这是对我有用的构造:
Ext.define('Sites', {
extend: 'Ext.data.Model',
fields: [
{name: 'inCphr', type: 'boolean'},
{name: 'department', type: 'string'},
{name: 'commune', type: 'string'},
{name: 'clinic', type: 'string'},
{name: 'sitecode', type: 'int'},
{name: 'dbsite', type: 'int'},
{name: 'ipAddress', type: 'string'},
{name: 'network', type: 'string'},
{name: 'lastChanged', type: 'date'}
]
});
var store = Ext.create('Ext.data.Store', {
model: 'Sites',
proxy: {
type: 'ajax',
url : 'getHaitiSites.php?task=get',
reader:{
type:'json',
root: 'results',
idProperty: 'sitecode'
}
}
});
如果你可以获得一个网格来显示“脏”元素,那么 store.getUpdatedRecords().length 将> 0。我看到一条评论表明这仅适用于 json 阅读器,但我不明白为什么它不会也不适用于其他数据结构。