zoukankan      html  css  js  c++  java
  • easyUI这样获取Json的内嵌数据 显示json下的json

    先给出返回的json数据。

    {
        "total": "2",
        "rows": [
            {
                "id": "1",
                "name": "张富银",
                "xiuhao": "2014009012",
                "exttend": {
                    "sid": "1",
                    "tid": "1",
                    "tel": "18580711609",
                    "qq": "564968550",
                    "email": "myfirtyou@qq.com",
                    "sxdw": "重庆源代码教育咨询有限公司",
                    "sxdw_add": "重庆市永川区",
                    "jjlxrtel": "15922879092"
                }
            },
            {
                "id": "4",
                "name": "测试学生姓名",
                "xiuhao": "2014009013",
                "exttend": {
                    "sid": "4",
                    "tid": "1",
                    "tel": "1234567890",
                    "qq": "12345",
                    "email": "test@qq.com",
                    "sxdw": "实习单位",
                    "sxdw_add": "单位地址",
                    "jjlxrtel": "1234567890"
                }
            }
        ]
    }

    昨天遇到这样一个问题,在取exttend里面的信息时,我使用了 如下的方式:

    {
         field: 'sxdw',
         title: '实习单位',
          60,
         formatter: function (value, rec) {
             return rec.extend.sxdw;
         }
     },

    这样可以取出sxdw的值,但是账号类型,性别也显示实习单位地址的值。不知道问题出在哪,在网上搜索,看到给出的解决办法都是返回 rec.extend.sxdw;这样,但是只返回一个字段,这样肯定可以返回正确的值了,但是我要返回的是很多个字段。真是没办法了,就随便试 试吧,我把field:’sxdw’改成field:’extend.sxdw,再运行一次,竟然得到了我想要的结果。

    下面是完整的代码:

     1 $('#student_list').datagrid({
     2         fit:true,
     3         fitColumns : true,
     4         rownumbers : true,
     5         border : false,
     6         striped : true,
     7         url:Thinkphp['MODULE']+'/student/getInfo/',
     8         toolbar : '#student_tool',
     9         rownumbers:true,//显示行号
    10         pagination:true,//显示分页工具条
    11         pageList : [15, 30, 45],
    12         pageNumber : 1,
    13         pageSize : 15,
    14         sortName : 'id',
    15         sortOrder : 'ASC',        
    16         columns:[[  
    17              {
    18                 field:'id',
    19                 title:'编号',
    20                 checkbox:true,
    21                 100,
    22             },{
    23                 field:'name',
    24                 title:'姓名',
    25                 sortable:true,
    26                 100,
    27             },{
    28                 field:'xiuhao',
    29                 title:'学号',
    30                 sortable:true,
    31                 100,
    32             },{
    33                 field:'exttend.teacher',
    34                 title:'指导教师',
    35                 sortable:true,
    36                 100,
    37             },    
    38             {
    39                 field:'exttend.tel',
    40                 title:'电话',
    41                 sortable:true,
    42                 100,
    43                 formatter: function (value, rec) {
    44                     return rec.exttend['tel'];
    45                 }
    46             },{
    47                 field:'exttend.qq',
    48                 title:'QQ',
    49                 80,
    50                 formatter: function (value, rec) {
    51                     return rec.exttend['qq'];
    52                 }
    53             },{
    54                 field:'exttend.email',
    55                 title:'电子邮件',
    56                 100,
    57                 formatter: function (value, row) {
    58                         return row.exttend.email;
    59                 }
    60             },{
    61                 field:'exttend.sxdw',
    62                 title:'实习单位',
    63                 150,
    64                 formatter: function (value, row) {
    65                         return row.exttend.sxdw;
    66                 }
    67             }, {
    68                 field:'exttend.sxdw_add',
    69                 title:'实习单位地址',
    70                 150,
    71                 formatter: function (value, row) {
    72                         return row.exttend.sxdw_add;
    73                 }
    74             },{
    75                 field:'exttend.jjlxrtel',
    76                 title:'紧急联系人电话',
    77                 100,
    78                 formatter: function (value, row) {
    79                         return row.exttend.jjlxrtel;
    80                 }
    81             },      
    82             ]] 
    83     });
    View Code
  • 相关阅读:
    centos crash debug
    go get Unknown SSL protocol error in connection to gopkg.in
    Tensorflow serving with Kubernetes
    Spring 集成 Swagger UI
    Docker Registry V2 Garbage Collection
    Docker Registry V2 with Nginx
    Zabbix磁盘性能监控
    Zabbix CPU utilization监控参数
    Windows挂载Gluster复制卷
    Redis持久化存储(三)
  • 原文地址:https://www.cnblogs.com/cms100/p/4190206.html
Copyright © 2011-2022 走看看