treeselect

提问 未结 1 567
杨星
杨星 2018-9-28
悬赏:20飞吻
我的返回数据格式正确
[{
"name": "捷智2",
"id": "e94e17c7-1d04-4893-b19f-3bf1cf43727a",
"children": [{
"name": "测试213",
"id": "e1f3a2da-cc96-400c-bfc9-60ba67005f01",
"children": [{
"name": "333",
"id": "9ee0a59e-b8bf-4610-bd0f-7cb0756ed354",
"children": null
}]
}, {
"name": "测试213",
"id": "e1f3a2da-cc96-400c-bfc9-60ba67005f01",
"children": [{
"name": "333",
"id": "9ee0a59e-b8bf-4610-bd0f-7cb0756ed354",
"children": null
}]
}, {
"name": "测试213",
"id": "e1f3a2da-cc96-400c-bfc9-60ba67005f01",
"children": [{
"name": "333",
"id": "9ee0a59e-b8bf-4610-bd0f-7cb0756ed354",
"children": null
}]
}, {
"name": "测试213",
"id": "e1f3a2da-cc96-400c-bfc9-60ba67005f01",
"children": [{
"name": "333",
"id": "9ee0a59e-b8bf-4610-bd0f-7cb0756ed354",
"children": null
}]
}, {
"name": "测试213",
"id": "e1f3a2da-cc96-400c-bfc9-60ba67005f01",
"children": [{
"name": "333",
"id": "9ee0a59e-b8bf-4610-bd0f-7cb0756ed354",
"children": null
}]
}, {
"name": "测试213",
"id": "e1f3a2da-cc96-400c-bfc9-60ba67005f01",
"children": [{
"name": "333",
"id": "9ee0a59e-b8bf-4610-bd0f-7cb0756ed354",
"children": null
}]
}]
}, {
"name": "jiezhi",
"id": "43bca13b-e2fd-4f1d-b0d2-3f15221bdc51",
"children": null
}, {
"name": "甲A",
"id": "9cd8f6e3-ec21-4cb1-ba8c-2ba0dd3f3723",
"children": null
}]

layui.config({
base: '../plugins/layui/extend/'
}).extend({
treeSelect: 'treeSelect'
}).use(['laydate', 'form', 'laypage', 'treeSelect'], function () {
form = layui.form;
laydate = layui.laydate;
laypage = layui.laypage;
treeSelect = layui.treeSelect;
treeSelect.render(
{
elem: "#TSDepartment",
data: '@Url.Action("GetSelectTree", "Membership")',
type: 'post',
key: {
id: 'ID',
},
// 节点点击回调函数
click: function (d) {
console.log(d);
}
});
laydate.render({
elem: '#Birthday' //指定元素
});
paging();
});

代码是这样的 但是只显示第一层的数据
请问有哪位大神帮忙看下

回帖
  • 雨时节
    2018-9-28
    不要传list.而应该是下面的格式:
    [{ //节点
    name: '父节点1'
    ,children: [{
    name: '子节点11'
    },{
    name: '子节点12'
    }]
    },{
    name: '父节点2(可以点左侧箭头,也可以双击标题)'
    ,children: [{
    name: '子节点21'
    ,children: [{
    name: '子节点211'
    }]
    }]
    }]
    0 回复