Completed
Last Updated: 22 Jun 2022 11:04 by ADMIN
ADMIN
Peter Milchev
Created on: 11 Aug 2016 08:53
Category: DropDownTree
Type: Bug Report
1
Collapsed nodes are expanded after filter is cleared

		
1 comment
ADMIN
Peter Milchev
Posted on: 11 Aug 2016 09:45
The solution is:

var collapsed = [];
function OnClientLoadHandler(sender, args) {
    $(sender.get_filterElement()).on('keydown', function (e) {
        var ddt = sender;
        var embeddedTree = ddt.get_embeddedTree();
        var nodes = embeddedTree.get_allNodes();
        if (ddt.get_filterElement().value == "") {
            collapsed = [];
            for (var i = 0; i < nodes.length; i++) {
                if (!nodes[i].get_expanded()) {
                    collapsed.push(nodes[i]);
                }
            }
        }

    })
    $(sender.get_filterElement()).on('keyup', function (e) {
        var ddt = sender;
        var tree = ddt.get_embeddedTree()
        var allNodes = tree.get_allNodes();
        if (ddt.get_filterElement().value == "") {
            setTimeout(function () {
                for (var i = 0; i < collapsed.length; i++) {
                    var node = tree.findNodeByValue(collapsed[i].get_value());
                    node.collapse(); 
                }
            }, 200);
        }
    })
}