dstore 中不存在 Observable,但有一个Trackable
mixin 可以代替。至于在从存储中获取新内容时更新网格,您可以使用 adstore/Cache
然后将Memory
混合的缓存存储传递Trackable
给网格以代替使用。每次将新数据添加到缓存存储时,它也会反映在网格中。
require([
'dgrid/OnDemandGrid',
'dstore/Rest',
'dstore/Memory',
'dstore/Trackable',
'dstore/Cache',
'dojo/domReady!'
], function (OnDemandGrid, Rest, Memory, Trackable, Cache) {
var restStore = new Rest({
target: '/mockRequest/'
});
var store = Cache.create(restStore, {
cachingStore: new (Memory.createSubclass(Trackable))()
});
var grid = new OnDemandGrid({
collection: store.cachingStore,
columns: {
id: 'ID',
name: 'Name',
description: 'Description'
},
loadingMessage: 'Loading...'
}, 'main');
grid.startup();
setInterval(function () {
store.fetch();
}, 2000);
});