当前位置:编程学习 > html/css >>

学习笔记:无限级目录删除(ID-PID模式),根据ID删除下面所有子ID

C#
private void DeleteByID(string id)
        {
            for (var i = 0; i < ZDemoData.DataList.Count; i++)
            {
                if (ZDemoData.DataList[i].id == id || ZDemoData.DataList[i].pId == id)
                {
                    var tx = ZDemoData.DataList[i].id;
                    ZDemoData.DataList.RemoveAt(i);
                    i = i - 1;
                    DeleteByID(tx);
                }
            }
        }
JS //删除 function DeleteByID(id,nodes) { for (var i = 0; i < nodes.length; i++) { if (nodes[i].id == id || nodes[i].pId == id) { var tx=nodes[i].id; nodes.splice(i, 1); i = i - 1; DeleteByID(tx, nodes) } } }

 

补充:web前端 , HTML/CSS  ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,