Dojo store duplication in cache
I am using a combination of dojo and cbtree to build a treeview with
checkboxes. Because the data is on the server I use a JsonRest store to
retrieve it. Because I don't want every action going to the server the
JsonRest is combined with a Memory in a Cache.
A simplified example looks like the following:
define([
'dojo/_base/declare',
'dojo/store/JsonRest', 'dojo/store/Memory', 'dojo/store/Cache',
'cbtree/model/TreeStoreModel', 'cbtree/Tree'
], function(declare,
JsonRest, Memory, Cache,
TreeStoreModel, Tree) {
return declare(null, {
buildTree: function() {
var self = this;
this._memory = new Memory();
this._restStore = new JsonRest({
target: '/process_trees/',
getSelectedItems: function() {
var checkedIds = [];
array.forEach(self._memory.query(), function(item) {
if(item.checked || item.checked == 'mixed') {
checkedIds.push(item);
}
})
return checkedIds;
}
});
var cache = Cache(restStore, memory);
this._treeModel = new TreeStoreModel({
store: cache
});
}
})
}
During the execution of the tree I check some items in the tree and I see
in the Cache the put function being called with the new item in which the
checked property is set to true and this value is stored in memory.
After a while I want to get all the items that are checked so I call the
getSelectedItems function but when I look in the local memory in the
function, self._memory, not a single item is checked even though I have
checked several items.
Does anybody know why this is happening?
No comments:
Post a Comment