z-tree 回顯所有選中的id

abcByme發表於2018-08-10
//回顯選擇的checkbox函式
function treeHxIdFun(obj) {
    var objTree = $.fn.zTree.init($("#demo"), setting, nodes);
    var zTreeObj = $.fn.zTree.getZTreeObj("demo");
    var zTree = objTree.getCheckedNodes(false);
    for(var i = 0; i < obj.length; i++){
        zTreeObj.checkNode(zTreeObj.getNodeByParam("id", obj[i]));
        zTreeObj.selectNode(zTreeObj.getNodeByParam("id", obj[i]));
    };
};

obj =[“34”, “3”, “34#add”] 陣列,id 與樹形的所有id 一致

相關文章