国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > WEB開發(fā) > 正文

easyUI這樣獲取Json的內(nèi)嵌數(shù)據(jù)

2024-04-27 15:09:12
字體:
供稿:網(wǎng)友

先給出返回的json數(shù)據(jù)。

123456789101112131415161718192021222324252627{"total":3,"rows":[        {"mobile":"13788888888",          "certificateCode":"370682xxxxxxxxxxxx",          "account":{                         "realName":"劉德華",                         "mobile":null,                         "certificateCode":"370682xxxxxxxxxxxx",                         "certificateType":"身份證",                         "accountType":"教工",                         "gender":"男",                         "address":"青島校區(qū)//網(wǎng)絡(luò)管理中心",                         "name":"0701468004",                         "id":37932                    },          "externalaccess":true,          "opTime":1314673484000,          "wlan":{                    "name":"移動(dòng)",                    "id":1                 },          "interAccess":true,          "id":19         }       ]}

昨天遇到這樣一個(gè)問題,在取account里面的信息時(shí),我使用了 如下的方式:

12345678910111213141516171819202122{     field:'account',     title:'真實(shí)姓名',     width: 60,     formatter:function (value, rec) {         return rec.account.realName;     } }, {     field:'account',     title:'賬號(hào)類型',     width: 60,     formatter:function (value, rec) {         return rec.account.accountType;     } }, {     field:'account',     title:'性別',     width: 50,     formatter:function (value, rec) {         return rec.account.gender;     } }

這樣可以取出realName的值,但是賬號(hào)類型,性別也顯示realName的值。不知道問題出在哪,在網(wǎng)上搜索,看到給出的解決辦法都是返回 rec.account.realName這樣,但是只返回一個(gè)字段,這樣肯定可以返回正確的值了,但是我要返回的是很多個(gè)字段。真是沒辦法了,就隨便試試吧,我把field:’account’改成field:’account.realName’,再運(yùn)行一次,竟然得到了我想要的結(jié)果。

下面是完整的代碼:

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115<head>    <title></title>    <link href="easyui/themes/default/easyui.CSS" rel="stylesheet" type="text/css" />    <script src="easyui/jquery-1.4.4.min.js" type="text/javascript"></script>    <script src="easyui/jquery.easyui.min.1.2.2.js" type="text/Javascript"></script>    <script type="text/javascript">        $(function () {            $("#ry").datagrid({                height: 500,                nowrap: true,                striped: true,                url: 'data.json',                columns: [[{                    field: 'mobile',                    title: '電話',                    width: 100,                    rowspan: 2                }, {                    field: 'certificateCode',                    title: '身份證號(hào)',                    width: 120,                    rowspan: 2                }, {                    title: '賬戶',                    colspan: 9                }, {                    field: 'externalAccess',                    title: '外部訪問',                    width: 60,                    rowspan: 2                }, {                    field: 'opTime',                    width: 120,                    rowspan: 2                }, {                    field: 'interAccess',                    title: '內(nèi)部訪問',                    width: 60,                    rowspan: 2                }                ],                [{                    field: 'account.realName',                    title: '真實(shí)姓名',                    width: 60,                    formatter: function (value, rec) {                        return rec.account['realName'];                    }                }, {                    field: 'account.mobile',                    title: '電話',                    width: 80,                    formatter: function (value, rec) {                        return rec.account['mobile'];                    }                }, {                    field: 'account.certificateCode',                    title: '身份證號(hào)',                    width: 120,                    formatter: function (value, rec) {                        return rec.account['certificateCode'];                    }                }, {                    field: 'certificateType',                    title: '證件類型',                    width: 60,                    formatter: function (value, rec) {                        return rec.account['certificateType'];                    }                }, {                    field: 'account.accountType',                    title: '賬號(hào)類型',                    width: 60,                    formatter: function (value, row) {                        return row.account.accountType;                    }                }, {                    field: 'account.gender',                    title: '性別',                    width: 50,                    formatter: function (value, row) {                        return row.account.gender;                    }                }, {                    field: 'address',                    title: '地址',                    width: 150,                    formatter: function (value, row) {                        return row.account.address;                    }                }, {                    field: 'name',                    title: '用戶名',                    width: 100,                    formatter: function (value, row) {                        return row.account.name;                    }                }, {                    field: 'id',                    title: 'Id',                    width: 60,                    formatter: function (value, row) {                        return row.account.id;                    }                }]],                pagination: true,                rownumbers: true            });        });    </script></head><body>    <table id="ry">    </table></body>

最后運(yùn)行效果如下:


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 武邑县| 丹阳市| 浮梁县| 平阳县| 台北县| 房山区| 四平市| 镇原县| 武山县| 临洮县| 汽车| 禄丰县| 香港 | 衡水市| 钟祥市| 沽源县| 临猗县| 凤台县| 浦江县| 泰安市| 长宁县| 石景山区| 河池市| 安西县| 沭阳县| 建宁县| 英山县| 四子王旗| 吉隆县| 盐山县| 平潭县| 林周县| 丽江市| 南宫市| 泰兴市| 临泽县| 泰顺县| 泾源县| 郓城县| 高阳县| 宝应县|