0
嗨,有人可以告诉我如何将一个数据存储复制到另一个数据存储。我以下面的方式尝试了它,但它不起作用。在这里,我尝试将数据从jsonStore复制到newGridStore。克隆/复制dojo数据存储
jsonStore.fetch({query:{} , onComplete: onComplete});
var onComplete = function (items, request) {
newGridStore = null;
newGridStore = new dojo.data.ItemFileWriteStore({
data : {}
});
if (items && items.length > 0) {
var i;
for (i = 0; i < items.length; i++) {
var item = items[i];
var attributes = jsonStore.getAttributes(item);
if (attributes && attributes.length > 0) {
var j;
for (j = 0; j < attributes.length; j++) {
var newItem = {};
var values = jsonStore.getValues(item, attributes[j]);
if (values) {
if (values.length > 1) {
// Create a copy.
newItem[attributes[j]] = values.slice(0, values.length);
} else {
newItem[attributes[j]] = values[0];
}
}
}
newGridStore.newItem(newItem);
}
}
}
}
在你这样做之前。你能解释你为什么要这么做吗? – Layke
Becouse用新值更新jsonStore之后,我需要将它们与旧值进行比较 – nath
然后你做错了。看到我的答案。 – Layke