$('#listTree').treegrid({
idField: 'id',
treeField: 'menuName',
columns: [[
{ title: 'Task Name', field: 'menuName', width: 180 },
{ field: 'menuUrl', title: 'progress', width: 60, align: 'right' }
]]
});
var data = { "total": 3, "rows": [{ "id": 0, "menuName": "管理员首页", "menuUrl": "/main/admin/index.action", "menuPCode": -1, "isLeaf": "0", "status": "1", "icon": "", "createUser": "system", "createDate": "2014-01-24 17:10:25", "modifyUser": "system", "modifyDate": "2014-01-24 17:10:25" }, { "id": 1, "menuName": "修改密码", "menuUrl": "/main/admin/modifyPwd.action", "menuPCode": 0, "isLeaf": "1", "status": "1", "icon": "", "createUser": "system", "createDate": "2014-01-24 17:10:25", "modifyUser": "system", "modifyDate": "2014-01-24 17:10:25", "_parentId": 0 }, { "id": 2, "menuName": "图片上传", "menuUrl": "/image/admin/uploadImage.action", "menuPCode": 1, "isLeaf": "1", "status": "1", "icon": "", "createUser": "system", "createDate": "2014-01-24 17:10:25", "modifyUser": "system", "modifyDate": "2014-01-24 17:10:25", "_parentId": 1 }], "footer": [{ "name": "Total Persons:", "persons": 7, "iconCls": "icon-sum" }] };
$("#listTree").treegrid('loadData', data);
$('#list').datagrid({
width: 1000,
height: 500,
columns: [[
{ title: 'Task Name', field: 'menuName', width: 180 },
{ field: 'menuUrl', title: 'menuUrl', width: 60, align: 'right' }
]]
});
var data = { "total": 3, "rows": [{ "id": 0, "menuName": "管理员首页", "menuUrl": "/main/admin/index.action", "menuPCode": -1, "isLeaf": "0", "status": "1", "icon": "", "createUser": "system", "createDate": "2014-01-24 17:10:25", "modifyUser": "system", "modifyDate": "2014-01-24 17:10:25" }, { "id": 1, "menuName": "修改密码", "menuUrl": "/main/admin/modifyPwd.action", "menuPCode": 0, "isLeaf": "1", "status": "1", "icon": "", "createUser": "system", "createDate": "2014-01-24 17:10:25", "modifyUser": "system", "modifyDate": "2014-01-24 17:10:25", "_parentId": 0 }, { "id": 2, "menuName": "图片上传", "menuUrl": "/image/admin/uploadImage.action", "menuPCode": 1, "isLeaf": "1", "status": "1", "icon": "", "createUser": "system", "createDate": "2014-01-24 17:10:25", "modifyUser": "system", "modifyDate": "2014-01-24 17:10:25", "_parentId": 1 }], "footer": [{ "name": "Total Persons:", "persons": 7, "iconCls": "icon-sum" }] };
$("#list").datagrid('loadData', data);
需要注意的是:data的数据,不是json字符串,是json对象