In 7.0RC2, some users have experienced delays / "script running slowly" errors when creating or incrementally loading trees with large amounts of data.
The following patch code reworks the Tree logic to link nodes together by parentID to be much more efficient for large numbers of interlinked nodes.
The following patch code reworks the Tree logic to link nodes together by parentID to be much more efficient for large numbers of interlinked nodes.
Code:
if (window.isc) { if (isc.version.startsWith("7.0rc2")) { isc.Tree.addProperties({ linkNodes : function (records, idProperty, parentIdProperty, rootValue, isFolderProperty, contextNode) { if (this.modelType == "fields") { this.connectByFields(records); return; } records = records || this.data; idProperty = (idProperty != null) ? idProperty : this.idField; parentIdProperty = (parentIdProperty != null) ? parentIdProperty : this.parentIdField; rootValue = (rootValue != null) ? rootValue : this.rootValue; var newNodes = []; newNodes.addList(records); var localNodeIndex = {}; for (var i = 0; i < newNodes.length; i++) { var id = newNodes[i][idProperty]; if (id != null) localNodeIndex[id] = newNodes[i]; } for (var i = 0; i < newNodes.length; i++) { var node = newNodes[i]; if (this.nodeIndex[node[idProperty]] == node) continue; if (node == null) continue; var newParentId = node[parentIdProperty], newParent = newParentId != null ? localNodeIndex[newParentId] : null, newParents = [] ; while (newParent != null) { if (newParent) newParents.add(newParent); newParentId = newParent[parentIdProperty]; newParent = newParentId != null ? localNodeIndex[newParentId] : null; } if (newParents.length > 0) { for (var ii = (newParents.length -1); ii >= 0; ii--) { this.$640(newParents[ii], idProperty, parentIdProperty, contextNode, rootValue); delete localNodeIndex[newParents[ii][idProperty]]; } } this.$640(node, idProperty, parentIdProperty, contextNode, rootValue); delete localNodeIndex[node[idProperty]]; } this.$27f(true); this.dataChanged(); } }); } else { isc.Log.logWarn("Patch code for SmartClient version 7.0RC2 included in this application. " + "You are running version:" + isc.version + ". This patch code will have no effect " + "and can be removed."); } }