首页 新闻 会员 周边 捐助

【请教】Jquery EasyUI TreeGrid 只显示数据没有树状结构是为什么?

0
悬赏园豆:20 [已关闭问题] 关闭于 2012-11-19 19:22

先上效果图:

其中

系统设置、会员管理 是一级菜单

其他有二级和三级菜单;

view 代码如下:

$(function () {
$('#easyui_grid').treegrid({
                title: '系统权限',
                //width: 700,
                height: 450,
                nowrap: false,
                rownumbers: true,
                animate: true,
                collapsible: true,
                method: 'post',
                //url: '/Scripts/jquery-easyui-1.3.1/demo/treegrid_data.json', //从远程站点获取数据
                url: '/Admin/Systems/Power_Manage_Json',
                idField: 'current_id', //说明哪个字段是一个标识字段
                treeField: 'current_id',

                columns:
                [[
                { title: '权限名称', field: 'power_name', width: 150 },
                    { field: 'power_src', title: '链接地址', width: 200, rowspan: 2 },
                    { field: 'power_deleted', title: '删除', rowspan: 2 },
                    { field: 'power_description', title: '描述', rowspan: 2 }

               ]],
                toolbar:
                [
                    {
                        text: '新增',
                        iconCls: 'icon-add',
                        handler: InsertData
                    }
                ],
                onLoadError: function (arguments) {
                    alert(arguments);
                }
               
            });
});

 

view html 如下:

<table id="easyui_grid">
</table>

 

服务端 /Admin/Systems/Power_Manage_Json 返回Json如下:

[{
    "power_id": "1",
    "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7543",
    "power_name": "系统设置",
    "power_src": "",
    "power_ico": "",
    "power_description": "",
    "power_index": "0",
    "power_parentid": "0",
    "power_deleted": "False",
    "power_deletedtime": "",
    "parent_id": "0",
    "current_id": "1",
    "children": [{
        "power_id": "8",
        "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7547",
        "power_name": "权限设置",
        "power_src": "",
        "power_ico": "",
        "power_description": "",
        "power_index": "0",
        "power_parentid": "1",
        "power_deleted": "False",
        "power_deletedtime": "",
        "parent_id": "1",
        "current_id": "8",
        "children": [{
            "power_id": "12",
            "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7551",
            "power_name": "权限管理",
            "power_src": "",
            "power_ico": "",
            "power_description": "",
            "power_index": "0",
            "power_parentid": "8",
            "power_deleted": "False",
            "power_deletedtime": "",
            "parent_id": "8",
            "current_id": "12"
        },
        {
            "power_id": "13",
            "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7552",
            "power_name": "角色管理",
            "power_src": "",
            "power_ico": "",
            "power_description": "",
            "power_index": "0",
            "power_parentid": "8",
            "power_deleted": "False",
            "power_deletedtime": "",
            "parent_id": "8",
            "current_id": "13"
        }]
    },
    {
        "power_id": "9",
        "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7548",
        "power_name": "仓库管理",
        "power_src": "",
        "power_ico": "",
        "power_description": "",
        "power_index": "0",
        "power_parentid": "1",
        "power_deleted": "False",
        "power_deletedtime": "",
        "parent_id": "1",
        "current_id": "9",
        "children": [{
            "power_id": "14",
            "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7553",
            "power_name": "新建仓库",
            "power_src": "",
            "power_ico": "",
            "power_description": "",
            "power_index": "0",
            "power_parentid": "9",
            "power_deleted": "False",
            "power_deletedtime": "",
            "parent_id": "9",
            "current_id": "14"
        },
        {
            "power_id": "15",
            "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7554",
            "power_name": "仓库维护",
            "power_src": "",
            "power_ico": "",
            "power_description": "",
            "power_index": "0",
            "power_parentid": "9",
            "power_deleted": "False",
            "power_deletedtime": "",
            "parent_id": "9",
            "current_id": "15"
        }]
    }]
},
{
    "power_id": "2",
    "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7541",
    "power_name": "会员管理",
    "power_src": "",
    "power_ico": "",
    "power_description": "",
    "power_index": "0",
    "power_parentid": "0",
    "power_deleted": "False",
    "power_deletedtime": "",
    "parent_id": "0",
    "current_id": "2",
    "children": [{
        "power_id": "10",
        "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7549",
        "power_name": "会员资料维护",
        "power_src": "",
        "power_ico": "",
        "power_description": "",
        "power_index": "0",
        "power_parentid": "2",
        "power_deleted": "False",
        "power_deletedtime": "",
        "parent_id": "2",
        "current_id": "10"
    },
    {
        "power_id": "11",
        "power_guid": "9cd32f9c-ab57-46e8-a8ac-f9cb1a7b7550",
        "power_name": "充值记录消费管理",
        "power_src": "",
        "power_ico": "",
        "power_description": "",
        "power_index": "0",
        "power_parentid": "2",
        "power_deleted": "False",
        "power_deletedtime": "",
        "parent_id": "2",
        "current_id": "11"
    }]
}]

 

 

然后我拿着 我自己生成的 这段 json 和 easy ui demos 里的 treeGrid json.data 数据逐行对比,实在是找不出来为啥,麻烦路过的高手告诉我  是否还缺少一个什么属性来表示父子关系?万分感谢。

西安-DB的主页 西安-DB | 初学一级 | 园豆:4
提问于:2012-11-18 20:20
< >
分享
所有回答(7)
0

是不是你的css没有引用正确?

一般的JS的插件都是有写css文件的

chenping2008 | 园豆:9836 (大侠五级) | 2012-11-18 20:23

应该不是,因为我把demos 中的代码复制到本页面上,引用css 和 js 的地方没有动过,可以正常显示。

支持(0) 反对(0) 西安-DB | 园豆:4 (初学一级) | 2012-11-18 20:32
0

看文档,格式是否正确

Qlin | 园豆:2403 (老鸟四级) | 2012-11-19 08:37
0

自己解决:

   TreeGrid 需要一个 treeField ,这个字段指定为要显示树状的字段name即可。

西安-DB | 园豆:4 (初学一级) | 2012-11-19 19:21

这是easyUI的bug不是楼主的问题,没试过不要乱说,用JS动态加载出来的页面里只能用HTML形式去创建对象,用JS形式就会显示不正常了,不知道easyui新版本有没有修正了这个bug

支持(0) 反对(0) yiyide266 | 园豆:200 (初学一级) | 2014-11-27 14:41
0

楼主怎么解决的了?使用table的话,折叠怎么有空白了

zxjcf520 | 园豆:202 (菜鸟二级) | 2015-01-08 14:36
0

treeField:'power_name'?

寂寞的阿飞 | 园豆:202 (菜鸟二级) | 2015-02-06 10:16
0

请问LZ 后来怎么解决的,我也遇到这个问题了

RookieMx | 园豆:206 (菜鸟二级) | 2015-07-27 21:13
0

 怎么解决的兄弟 

纵观全局 | 园豆:249 (菜鸟二级) | 2016-07-14 17:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册