设为首页 加入收藏

TOP

easyui中combotree循环获取父节点至根节点并输出路径
2015-07-20 17:22:48 来源: 作者: 【 】 浏览:2
Tags:easyui combotree 循环 获取 节点 输出 路径

前台页面:

    ??
    ??

JavaScript页面(包括数据初始化):

initAEType: function () {
    $.ajax({
        url: AEActionUrl + '?action=listaetype&ParentType=',
        dataType: 'json',
        success: function (jsonstr) {
            $('#fm_AEType').combotree({
                data: jsonstr,
                editable: false,
                //lines: true,
                valueField: 'AE_TYPE_ID',
                textField: 'AE_TYPE_NAME',
                onLoadSuccess: function () {
                    $('#fm_AEType').combotree('tree').tree("collapseAll");
                },
                onSelect: function (item) {
                    var parent = item;
                    var tree = $('#fm_AEType').combotree('tree');
                    var path = new Array();
                    do {
                        path.unshift(parent.text);
                        var parent = tree.tree('getParent', parent.target);
                    } while (parent);
                    var pathStr = '';
                    for (var i = 0; i < path.length; i++) {
                        pathStr += path[i];
                        if (i < path.length - 1) {
                            pathStr += ' - ';
                        }
                    }
                    $('#fm_AETypePath').text(pathStr);
                }
            });
        }
    });
}

如上,关键代码在onSelect事件中。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇poj 1905 (二分查找) 下一篇poj 3122 (二分查找)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何理解c语言指针和 (2025-12-27 01:19:11)
·为什么C标准库没有链 (2025-12-27 01:19:08)
·玩转C语言和数据结构 (2025-12-27 01:19:05)
·MySQL 基础入门视频 (2025-12-26 23:20:22)
·小白入门:MySQL超详 (2025-12-26 23:20:19)