jquery ztree 怎么从前台动态获取后台数据-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

jquery ztree 怎么从前台动态获取后台数据

a123456678 2016-07-06 10:12:45 2433

请问下 我想用ajax动态的从后台获取地区的数据 怎么获取 下面这是一个静态的 !

<SCRIPT type="text/javascript">
        <!--
        var setting = {
            view: {
                showIcon: showIconForTree
            },
            data: {
                simpleData: {
                    enable: true
                }
            }
        };
 
        var zNodes =[
            { id:1, pId:0, name:"父节点1 - 展开", open:true},
            { id:11, pId:1, name:"父节点11 - 折叠"},
            { id:111, pId:11, name:"叶子节点111"},
            { id:112, pId:11, name:"叶子节点112"},
            { id:113, pId:11, name:"叶子节点113"},
            { id:114, pId:11, name:"叶子节点114"},
            { id:12, pId:1, name:"父节点12 - 折叠"},
            { id:121, pId:12, name:"叶子节点121"},
            { id:122, pId:12, name:"叶子节点122"},
            { id:123, pId:12, name:"叶子节点123"},
            { id:124, pId:12, name:"叶子节点124"},
            { id:13, pId:1, name:"父节点13 - 没有子节点", isParent:true}
        ];
 
        function showIconForTree(treeId, treeNode) {
            return !treeNode.isParent;
        };
 
        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });
        //-->
    </SCRIPT>
 
</HEAD>
 
<BODY>
<h1>不显示节点图标的树</h1>
<div class="content_wrap">
    <div class="zTreeDemoBackground left">
        <ul id="treeDemo" class="ztree"></ul>
    </div>
</BODY>
</HTML>
前端开发 JavaScript
分享到
取消 提交回答
全部回答(1)
  • a123456678
    2019-07-17 19:51:52
    3.X的是这样写的
    
          var setting = { 
    
                checkable : true,
    
                callback : {
    
                    onClick:  zTreeOnClick
    
                },
    
                expandSpeed :"fast",
    
                async: {
    
                    enable: true,
    
                    url:"getTreeNode.jsp",
    
                    autoParam:["id","name"],
    
                    dataFilter: null
    
                },
    
                view: {
    
                    showLine: false,
    
                    dblClickExpand :false
    
                }};
    
     $.fn.zTree.init($("#sidebar"), setting);
    0 0

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程