mitchellsimoens
16 Mar 2011, 8:41 AM
In the WebStorageProxy, the getIds method you parse the id of each record into an integer but why? Why can't you have an id with letters and even symbols?
Override to fix:
Ext.override(Ext.data.WebStorageProxy, {
eliminateDuplicates : function(arr) { //could go into Array prototype (prob better name)
var i = 0,
x = 0,
len = arr.length,
out = [],
obj = {};
for (; i < len; i++) {
obj[arr[i]] = 0;
}
for (i in obj) {
if (Ext.isDefined(i)) {
out.push(i);
}
}
return out;
},
setIds: function(ids) {
if (ids[0] === '') { delete ids[0]; }
ids = this.eliminateDuplicates(ids);
var obj = this.getStorageObject(),
str = ids.join(",");
obj.removeItem(this.id);
if (!Ext.isEmpty(str)) {
obj.setItem(this.id, str);
}
},
getIds: function() {
//first time will be right but after that will return duplicates. Why?
var ids = (this.getStorageObject().getItem(this.id) || "").split(","),
length = ids.length,
i;
return ids;
}
});
Override to fix:
Ext.override(Ext.data.WebStorageProxy, {
eliminateDuplicates : function(arr) { //could go into Array prototype (prob better name)
var i = 0,
x = 0,
len = arr.length,
out = [],
obj = {};
for (; i < len; i++) {
obj[arr[i]] = 0;
}
for (i in obj) {
if (Ext.isDefined(i)) {
out.push(i);
}
}
return out;
},
setIds: function(ids) {
if (ids[0] === '') { delete ids[0]; }
ids = this.eliminateDuplicates(ids);
var obj = this.getStorageObject(),
str = ids.join(",");
obj.removeItem(this.id);
if (!Ext.isEmpty(str)) {
obj.setItem(this.id, str);
}
},
getIds: function() {
//first time will be right but after that will return duplicates. Why?
var ids = (this.getStorageObject().getItem(this.id) || "").split(","),
length = ids.length,
i;
return ids;
}
});