接合easyui 的父子级关系

<script type="text/javascript">
    $(function () {
        var data = [
         { id: 1, pid: 0, name: '新城控股集团' },
         { id: 2, pid: 1, name: '总裁' },
         { id: 7, pid: 6, name: '税务管理888' },
         { id: 8, pid: 3, name: '税务管理' },
         { id: 9, pid: 3, name: '规划建筑副总监' },
         { id: 3, pid: 1, name: '财务管理中心' },
         { id: 4, pid: 0, name: '新城' },
         { id: 5, pid: 2, name: '总经理' },
         { id: 6, pid: 5, name: '商业财务管理副经理' },
         { id: 10, pid: 9, name: '企划主管' },
         { id: 11, pid: 9, name: '招商副总监'}];
        var root = { id: 0, name: 'Root', items: [] };
        var pItems = { 0: root };
        var i = 0, item = {};
        for (; i < data.length; i++) {
            item = data[i];
            item.items = new Array();
            pItems[item.id] = item;
        }
        for (i = 0; i < data.length; i++) {
            item = data[i];
            pItems[item.pid].items.push(item);
        }
        debugger;
    });    </script>

posted @ 2012-05-18 16:31  易独  阅读(260)  评论(0编辑  收藏  举报
乐巴儿 一个有声音的公众号
长按,识别二维码,加关注