easyUI combotree 的异步加载

本文介绍了一种使用异步请求加载树形数据的方法,通过$.post发起HTTP请求获取数据,然后利用totree函数将JSON数据转换为树形结构。在用户选择节点时,会触发onBeforeSelect事件,此时再次发送请求加载子节点数据并动态添加到树中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

$.post("http://xxxxxxxx.action", {
        "pid" : null
    }, function(json) {

       let mydata = totree(json)

        $('#cc').combotree({
            data:mydata,
            parentField : 'pid',
            required: true,
            onBeforeSelect: function (node) {
                console.log(node)
               
                $.post("http://xxxxxxxx.action", {
                    "pid" : node.id
                }, function(json) {
                    if (node.children && node.children.length){return}
                    var tree = $('#cc').combotree('tree')
                    tree.tree('append', {
                        parentField : 'pid',
                        parent: node.target,
                        data: json
                    });
                    
                    // $("#"+node.target.id).next().show()
                }, "json");

                // debugger;
                if (!$(this).tree('isLeaf', node.target)) {
                    // $(this).combo("showPanel");
                    return false;
                }


            },

        });
    }, "json");

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值