Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartClient 7.0rc2:Patch for issue with trees and ID:0

    In SmartClient version 7.0rc2, an issue exists whereby if hierarchical data is loaded dynamically from the server, if a node has its parentId property set to zero, it can be added to the root node rather than to the node whose Id is set to zero.

    This has now been resolved in SmartClient's internal codebase. Here's some patch code to resolve this issue if encountered:
    Code:
    if (window.isc && isc.version.startsWith("7.0rc2/")) {
    if (isc.Tree) {
    isc.Tree.addProperties({
    $640:function (_1, _2, _3, _4, _5) {
        var _6 = this.logIsDebugEnabled(this.$64z);
        var _7 = _1[_2], _8 = _1[_3], _9 = _8 == null || _8 == -1 || _8 === isc.emptyString, _10 = this.nodeIndex[_8];
        if (_10) {
            if (_6) {
                this.logDebug("found parent " + _10[_2] + " for child " + _1[_2], this.$64z);
            }
            this.$27e(_1, _10);
        } else if (_8 == _5) {
            if (_6) {
                this.logDebug("root node: " + _1[_2], this.$64z);
            }
            this.$27e(_1, this.root);
        } else {
            if (!_9 && this.discardParentlessNodes) {
                this.logWarn("Couldn't find parent: " + _8 + " for node with id:" + _7, this.$64z);
            } else {
                var _11 = _4 || this.root;
                if (_6) {
                    this.logDebug("child:" + _1[_2] + (_9 ? " has no explicit parent " : " unable to find specified parent:" + _8) + "- linking to default node " + _11[_2], this.$64z);
                }
                this.$27e(_1, _11);
            }
        }
    },
    $27e:function (_1, _2, _3) {
        var _4 = _1[this.idField];
        if (_4 != null && this.modelType == isc.Tree.PARENT) {
            var _5 = this.findById(_4);
            if (_5) {
                this.$580(_4);
                this.remove(_5);
            }
        }
        this.getName(_1);
        this.convertToFolder(_2);
        var _6 = _2[this.childrenProperty];
        if (!_6) {
            _6 = _2[this.childrenProperty] = [];
        }
        if (_6 != null && !isc.isAn.Array(_6)) {
            _2[this.childrenProperty] = _6 = [_6];
        }
        if (_3 == null || _3 > _6.length) {
            _6.add(_1);
        } else {
            _6.addAt(_1, _3);
        }
        var _7 = this.idField;
        _1[this.parentIdField] = _2[_7];
        _1[this.parentProperty] = _2;
        _1[this.treeProperty] = this.ID;
        if (_1[_7] != null) {
            this.nodeIndex[_1[_7]] = _1;
        }
        this.setLoadState(_2, isc.Tree.LOADED);
        var _8 = _1[this.childrenProperty];
        if (_8 != null) {
            _1[this.childrenProperty] = [];
            if (!isc.isAn.Array(_8)) {
                this.$27e(_8, _1);
            } else if (_8.length > 0) {
                this.$27k(_8, _1);
            }
            this.setLoadState(_1, isc.Tree.LOADED);
        } else {
            var _9 = _1[this.isFolderProperty];
            if (_9 != null && !isc.isA.Boolean(_9)) {
                _9 = isc.booleanValue(_9, true);
            }
            if (_9 == null && this.defaultIsFolder) {
                _9 = true;
            }
            _1[this.isFolderProperty] = _9;
        }
    }
    });
    }
    } else if (window.isc) {
        isc.Log.logWarn("Patch for 7.0rc2 included in this application but you are running version:" +
            isc.version + ", this patch will have no effect in this build and should be removed."); 
    }
Working...
X