z-tree用法

setting参数设置

var setting = {
    async : {
        enable: true,
        type: "get",
        url: "../../eldercare/service/serviceCarrier/selectServiceCarrier",
        // autoParam: ["serviceCarrierId"]
    },
    data : {
        simpleData : {
            enable : true,
            idKey : "id",
            title : "supplierName",
            pIdKey : "0",
            rootPId : ""
        },
        key : {
            url : "nourl"
        }
    },
    callback : {
        onClick : function(event, treeId, treeNode) {
            vm.keyword.serviceCarrierId = treeNode.id;
            vm.load();
        }
    }
};

ztree初始化

//r为后端返回的list
var array = r;
array.splice(0,0,{ id:null,name:'全部机构'});//手动设置一个root节点
var ztree = $.fn.zTree.init($("#cjjgTree"), setting, array);

你可能感兴趣的:(z-tree用法)