想要建立一个具有可扩展链接的子级和子级子节点的树形结构

时间:2018-07-18 12:09:13

标签: jquery json

function getTreestructure() {
	
 //var woId =localStorage.getItem("selectedWONo");       
 var data = [

{
    "Node":"C",
    "WorkId":12,
    "WOParentWONo":"101"
}, 
{
    "Node":"C",
    "WorkId":13,
    "WOParentWONo":"101"
},

 
{
    "Node":"B",
    "WorkId":101,
    "WOParentWONo":"900"
}, 
{
    "Node":"A",
    "WorkId":900,
    "WOParentWONo":NULL
}

]	  
$(function() {
    $('#tree1').tree({
        data: data
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="https://blueimp.github.io/Gallery/js/jquery.blueimp-gallery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<script src="custom/plugins/blueImp/js/tree.jquery.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jqtree/1.4.7/jqtree-circle.png"></script> 

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqtree/1.4.7/jqtree.css"></script>

<body>
<div id="tree1"></div>
</body>

    {
        "Node":"B",
        "WorkId":101,
        "WOParentWONo":"900"
    }, 
    {
        "Node":"A",
        "WorkId":900,
        "WOParentWONo":NULL
    }

]

想要构建树结构,当"WOParentWONo"为NULL时,ParentNode不可使用子节点,如果找到WOParentWONo则为该ParentNode的子节点。

0 个答案:

没有答案