When developing the front-end time, you need. data. store the data in the store to a variable first, then the data in the store will be cleared, and finally the data in the variable will be loaded into the store.
The Code is as follows:
var tempData = this.store.data.clone();/* Something else */this.store.loadData([]);/* Something else */this.store.loadData(tempData);
At this time, you will find that when the last row is executed, the size of tempdata is already 0. Why?
The answer is that the clone of data (ext. util. mixedcollection) is a light copy.
Clone (): Ext. util. mixedcollection
Creates a shallow copy of this collection
Available since:4.0.0
Returns
- Ext. util. mixedcollection
To meet our needs, we must implement a deepcopy operation by ourselves:
var tempData = this.store.data;var r = new Ext.util.MixedCollection();var keys = tempData.keys;var items = tempData.items;for(var i = 0, len = items.length; i < len; i++){ r.add(keys[i], items[i].copy());}this.store.loadData([]);for (var i = 0, len = r.items.length; i < len; i++) { this.store.loadData([r.items[i].data], true);}
How data is cloned in Ext. Data. Store