EXTJS7 treestore 获取所有记录
treestore如果从根节点遍历树获取所有记录太麻烦
版本
7.x
解决
使用treestore.byIdMap即可获取根据记录ID映射的所有记录
源码分析
modern/src/TreeStore.js
Ext.define('Ext.data.TreeStore', {
registerNode: function(node, includeChildren) {
var me = this,
was = me.byIdMap[node.id],
children, length, i;
// Key the node hash by the node's IDs
me.byIdMap[node.id] = node;
// If the node requires to be informed upon register, and is not already
// registered, keep it informed.
if (node.onRegisterTreeNode && node !== was) {
node.onRegisterTreeNode(me);
}
// Keep a count of nodes which require to be informed upon unregister.
// If we are destroyed, or change root nodes, a cascade will be
// necessary if this is non-zero.
if (node.onUnregisterTreeNode) {
me.nodesToUnregister++;
}
if (includeChildren === true) {
children = node.childNodes;
length = children.length;
for (i = 0; i < length; i++) {
me.registerNode(children[i], true);
}
}
},
});