jstree 反选,测试400条数据左右有点卡

$("#reversecheckallmachines").on("change", function () {
                    var checkedNodes = [];
                    var uncheckedNodes = [];

                    var nodes = $tree.jstree("get_json", null, { flat: true });
                    for (var i = 0; i < nodes.length; i++) {
                        if (nodes[i].state.selected) {
                            var findNode = nodes.find(x => x.parent === nodes[i].id);
                            if (!findNode) {
                                checkedNodes.push(nodes[i]); 
                            }
                        }
                        else {
                            var fnode = nodes.find(x => x.parent === nodes[i].id);
                            if (!fnode) {
                                uncheckedNodes.push(nodes[i]); 
                            }
                        }
                    }
                    $tree.jstree("uncheck_node", checkedNodes);
                    $tree.jstree("check_node", uncheckedNodes); 
                });

相关推荐